Java Learning 1_ some basic 1--16.5.4

Source: Internet
Author: User

Each Java program must have a main method in the form of:

 Public class classname{    publicstaticvoid  main (string[] args)     {          Program Statements     }       }      

The main method in Java must be static.

System.out.println ("Hello world!");

Here, the System.out object is used. and call its Println method. The point number (.) is used to invoke the method.

System.out.print ();//output does not wrap.

Data type:

int 4 bytes

Short 2 bytes

Long 8 bytes

Byte 1 bytes

Java does not have any unsigned type (unsigned).

Float 4 bytes

Double 8 bytes

If you need to have no rounding errors in a numeric calculation, you should use the Biddecimal class.

Char

Boolean:false/true.

Variable:

Variable name: A sequence of letters or numbers beginning with a letter.

Variable declarations, initialization, and assignment are similar to C.

Constant:

In Java, the final keyword is used to indicate a constant, and final indicates that the variable can only be assigned once and cannot be changed later.

Static final class constant, which can be used in multiple methods within a class.

The operator is roughly the same as C no longer looks.

String:

String

String e= "Hello";

Sub-string :

The substring method of the string class can extract a smaller string from a larger string:

String greeting= "Hello";

String s=greeting.substring (0,3);//The second parameter is the first position that you do not want to copy, and this call takes out the 0,1,2 bit

Stitching:

Available + number stitching two strings:

String a= "Hello";

String b= "World";

String c=a+b;

When stitching strings and non-strings, the latter is converted to strings.

Java Learning 1_ some basic 1--16.5.4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.