The basic composition of a programming language: character sets, identifiers, keywords, variables, constants, statements.
Cnost and Goto can no longer be used in Java.
Mian is a special name used to describe the starting method of a Java program, but it is not a keyword.
Naming rules for Java identifiers:
1. Cannot be a keyword or true, false, null.
2. Identifiers can contain letters, numbers, underscores, dollar signs.
3. The first character of an identifier must be a letter, underscore, or dollar sign.
4. Identifiers are case-sensitive and do not specify a maximum length.
Java Data type:
Byte 1 bytes (8 bits) short 2 bytes (16 bits) int 3 bytes (32 bits) long 4 bytes (64 bits)
Float 4-byte (32-bit) Double 9-byte (64-bit) Char 2-byte (16-bit) Boolean determined by the JVM
Sting string
How to convert between Java base data types:
1. All byte, short and char types will be promoted to int type
2. If one of the operands is a long type, the result is a long
3. If one of the operands is of type float, the result is a float type
4. If one of the operands is of type double, the result of the calculation is a double type
Pre-or post-increment/decrement ++/--unary operator + 、-、 ~,! Multiplication/Division/modulus */%
Add/Subtract/string links + 、-、 + move operators <<, >>, >>> comparison operators <, <=, >, >=
Equality operator = =,! = bitwise operator &, |, ^ condition and,or &&, | |
Trinocular operator? : Assignment operator = Extended assignment operator *=,/=,%=, + =,-=, <<=, >>=,
>>>=, &=, ^=, |=
Package dome;
public class Dome {
/**
* @param args
*/
public static void Main (string[] args) {
//TODO auto-generated method stub
//shift operator
//Shift left
int result1=3<<5;power of//3*2 5 times
System.out.println (RESULT1);
//Right Shift
int result2=-24>>3;//4 divided by 2 to the power of 3.
System.out.println (RESULT2);
//Right Shift 0
int result3=1024>>>2;
System.out.println (RESULT3);
//Extended assignment operator
//1.+=
int number1=10;
number1+=5;
//10+5
System.out.println (NUMBER1);
//2.-=
int number2=10;
number2-=5;
//10-5
System.out.println (NUMBER2);
//3.*=
int number3=10;
number3*=5;
//10*5
System.out.println (NUMBER3);
//4./=
int number4=25;
number4/=4;
//25/4 take integer
System.out.println (NUMBER4);
//5.%=% remainder
int number5=10;
number5%=3;
//10/3 take remainder
System.out.println (NUMBER5);
//String connector +
String str1= "Hello";
String str2= "World";
String str3= "Hello" + "world";
System.out.println (STR1+STR2+STR3);
//Three mesh operator
//Expression 1? Expression 2: Expression 3
int a=1;
int b=2;
int c=a++>b--? ++a:--b;
System.out.println (c);
System.out.println (a);
Java Chapter II Summary