Java key terms
Simplicity, object-oriented, distributed, robustness, security, architecture neutrality, portability, interpreted, high performance, multithreading, dynamic
The difference between JDK and JRE
JDK: Java Development Kit (java development kit)
JRE: Java Runtime Environment (java runtime environment)
JRE is a java runtime environment, including java virtual machine, java basic class library. It is the software environment required for running programs written in java language, and is provided to users who want to run java programs.
JDK is a java development kit, a development kit required by programmers to write java programs in java language, and is provided for programmers to use. JDK includes JRE, as well as javac, a compiler for compiling java source code, as well as many tools for debugging and analyzing java programs: jconsole, jvisualvm and other tools, as well as documentation and demo example programs required for writing java programs. .
HelloWorld
public class HelloWorld {
/**public 访问修饰符,用于控制程序的其他部分对这段代码的访问级别。
* class 类
* HelloWorld 类名
* main是程序的入口
* */
public static void main(String[] args) {
/*java注释*/
//java注释
/*
*java 多行注释
**/
System.out.println("Hello World!");
}
}
Eight basic types of java
int 4 bytes
short 2 bytes
long 8 bytes
byte 1 byte
float 4 bytes
double 8 bytes
char The literal value of char type should be enclosed in single quotes
boolean Boolean type only has true and false
1 byte (Byte) = 8 bits (bit)
eight basic data types: byte, short, int, long, float, double, boolean, char.
Operator
Operators are used to connect values.
Arithmetic operators +-* /% take remainder
. The general form of ternary operation is: expression 1? expression 2: expression 3;
for example, min=(a<b)?a:b;
Bit operation (shift, and &, or |, exclusive or ^, not ~)
shift is divided into left shift <<, right shift >>, unsigned left shift <<<, unsigned right shift >>>
Mathematical function
Math.exp(x) //Returns the arithmetic constant E to the power of x
Math.sqrt(x) //return the square root of x
Math.ceil(x) //Math.ceil(10.1) =>11(advance one)
Math.floor(x) // Math.floor(15.6) =>15(去尾)
Math.rint(x) //Round to the nearest integer of x, return an even integer if the distance is equal
Math.round(x) //Round to integer
Math.min/max Math.abs //returns the minimum and maximum of two numbers/returns the absolute value
Math.pow(a,b) //return a to the b power