JAVA Language Overview Notes

/ * 1 1995Sun company Oracle Oracle Corporation

2 command prompt start key is turned on + r 

    Change your disk drive letter name: cd tab key to switch into file file cd .. cd layer on return \ path back to the root dir cls Clear the screen to view the current path to the file exit exit

3 keywords entirely lowercase letters with special colors are reserved for special meanings

4 identifiers can contain 26 letters and 0-9 $ _ can not begin with a number can not be keywords   

Naming convention: class name all large camel-capitalized variable names and method names first letter lowercase small hump the rest of the word capitalized

5 Constant * /

{the Main class public 

public static void main (String [] args) {
// string constant
of System.out.print ( "ABC");
of System.out.print ( ""); // string of two intermediate double quotes the content is empty
// integer constant
System.out.print (200);
System.out.print (20);
// floating point (decimal) constant
System.out.print (0.1);
// character constant
System.out .print ( '. 4');
//System.out.print ( ''); character can not be empty
// Boolean constants
of System.out.print (to true);
of System.out.print (to false);
// null constant
//System.out.print(null); can not be directly outputted

}
}
/ * 6 elementary data type
Integer type byte short int long float double floating-point type character type char boolean boolean
reference data types
string array class interfaces Lambda
Notes: 1 string is not a basic type but references
2 may be a floating-point approximation is not accurate
3 range of data type does not necessarily correlate with the number of bytes is four bytes, for example, float, but a wide range is 8 bytes long
if it is an integer type use defaults to long int L suffix required
if the default is the fractional type double float requires use suffix F.
. 7 data type conversion
automatically converts the code does not need to process an automatic conversion rule 2: data range from small to large conversion * /

  new new class. 1 {public
    public class void main (String [] args) {
System.out.println (400); // This is an integer, the default is int.
System.out.println (3.14); // This is a floating-point number, the default is double.
// left is long type, the right is not the same around int type
// equals sign represents the assignment a long int variables constant on the right to the left to be stored
// int -> long data range from small to large transformation occurs
long = 100 num1;
System.out.println (num1);
}
}

/ * Cast

1 Features: format code needs to be v care, can not be done automatically.

Format 2: small type of variable name = range (small type) had a large range of data;

Precautions

1 casts are generally not recommended, because the data may lead to loss of precision data overflow.

2byte / short / char three types can occur mathematical operations, such as addition "+."

3byte / short / char when these three types of data operation is first promoted to the int type, then calculate.

4boolean type Data type conversion can not happen * /

public class Demo02DataType{

  public static void main(String[] args){

// int type is left, the right is long type, not the same.

// long -> int, not from small to large, automatic data type conversion can not take place

int num = (int) 100L;

// long casts to an int

int num2=(int)600000000000L;

System.out.println(num2);//1705032704

// double -> int, cast type

int num3=(int)3.99;

System.out.println (num3); // 3, but this is not a rounding rounding

char zifu1 = 'A'; // this is a character constant, there is a capital letter A

System.out.println (zifu1 + 1); // 66, the letter A is also treated as a 65

Hi // underlying computer should a digital (binary) to represent the letter A is 65

// bit char type of mathematical operations will be carried out according to certain rules have been translated into a number

byte num4 = 40; // the left of the right size can not exceed the value range type

byte num5=50;

//byte+byte-->int+int-->int

int result1=num4+num5;

System.out.println(result1);//90

short num6=60;

//byte+short-->int+int-->int

// int casts become short: Note that you must ensure that the logic is really no more than the size of the already short range, otherwise the data overflow will occur

short result2=(short)(num4+num6);

System.out.println(result2);

 

}

}

ASCII code table: American Standard Code for Information Interchange, American Standard Code for Information exchange

Unicode code table: Unicode. Control relationship is also the beginning of the 0-127 numbers and symbols with ASCII exactly the same, but from the beginning to include 128 more characters

A 65  0 48  a 97

 

Guess you like

Origin www.cnblogs.com/xzwx668/p/11939098.html