1. Variable: A basic unit that stores data.
2. Declaration and assignment of variables:
1) Declare and assign values; data type variable name = value for example: int prince=10;
2) Declaration, assignment is divided into two steps: Data type variable name; for example: Int=price;
Variable name = value For example: price=10
3. There are two types of data:
1) Basic data type eight kinds:
Byte (-2 of 7 square to 2 of 7 square-1)
Short (-2 of 15 parties to 2 of 15 parties-1)
Int (-2 of 31 Square to 2 of 31 square-1)
Long (-2 of 63 square to 2 of 63 square-1) 99l
float Float Type 99f
Doubles double prince=32.5
Boolean True (True) False (False) Boolean isbrand=true;
Char one character, two byte range is 0-65535 reference ASCII character encoding table
Char sex= ' male '; char num=65; (Output a)
2) Reference data type:
String Strings name= "Zhang San";
Class
Interface
4. Variable Naming conventions:
English words or pinyin
Initials: Start with letters, underscores, and $
When multiple words are made up of variable names: Named by the Hump-type nomenclature. Example: Studentname
The name of the variable should be the result of knowing the meaning of the name
5. Assignment Operator: = Assign the right value to the left
6. Arithmetic operators: +-*/(except)% (take surplus)
7. num++; num=num+1; Num+=1;
num--; Num=num-1; Num-=1;
System.out.println (--num);//calculate and re-output first
System.out.println (num--);//First output recalculation
8.double avg= (90+99)/3.0 automatic type conversion occurs
Automatic conversion type conditions:
1) Type-compatible: (int and double are numeric)
2) The target type is greater than the source type: (double greater than int)
9. Coercion type conversion: (data type) variable name (data type) value
For example: Double num=5.5; int result= (int) num;
int result= (int) 5.5;
Java Fundamentals-variables, data types, and operators