A. Java basic concepts
JVM English Java Virtual Machine, Java virtual machine, Java runtime environment, java file after the command javac bytecode files compiled form (class files), Java virtual machine executes bytecode files, explained that specific byte code file machine instructions executed on the platform, which is a Java program " compile once, run anywhere " principle.
JRE English Java Runtime Envirment, Java Runtime Environment, JRE is essential for running Java programs, including the JVM and Java core libraries.
JDK English Java Development Kit, Java Development Kit, jdk is the core Java development, including the Java runtime environment jre, a bunch of Java tools (compiler debugging tools such as javac, java, jdb), Java Foundation Classes.
To sum up can be summarized on the relationship between the three: JDK> JRE> JVM.
II. Identifier
1. Naming
Identifier contains class names, method names, variable names and the like.
Specific rules are:
- Must consist of the dollar sign $, numbers, underscores _ and English letters.
- Initials not be a number
- Identifiers case sensitive
- Identifier can not be keywords, specific keywords Baidu View
2. Variable Types
Java variable types are divided into basic data types and reference types.
The basic data types There are eight major species
Variable Types | Byte count | Default initial value |
---|---|---|
byte | 1 | 0 |
short | 2 | 0 |
int | 4 | 0 |
long | 8 | 0 |
boolean | 1 | false |
char | 2 | \ U0000 |
float | 4 | 0.0 |
double | 8 | 0.0 |
Note: \ u0000 is the null character, nothing output test, but do not think it is a space.
3. The variable conversion
Conversion rules are as follows:
Small type automatically converted to large data types
byte,short,char -->int --> long --> float --> double
Without conversion between short, byte, char
boolean does not automatically convert any type
During operation, when the operation int type, int type a result, the above operation result of an int type involved in computing the largest type.
4. Operators
Arithmetic operators: +, -, *, /,%, +, -
Assignment operator: =, + =, - =, * =, / =,% =
Logical Operators:! , &, |, &&, ||
Bitwise operators: <<, >>, >>>, &, |, ^, ~
Trinocular conditional operator: x y:? Z
Note: << is left, as signed right shift >>, >>> unsigned right. && and || operator as a short circuit.
int a= 102;
a %= 10*10 + 1;
System.out.println(a);//输出1