I never expected to start school in advance. Reverse engineering needs to learn Java. Challenge 10 days to learn a new language~
The textbook used is recommended by the teaching assistant. Station b: the latest and most complete Java introductory basic tutorial Dark Horse Membership Edition-supporting classroom code data
The first program: Hello World
public class hello {
//类名必须和文件名完全一样
public static void main(String[] args){
//main方法,代表程序执行的起点
System.out.println("Hello,World");//打印输出语句
}
}
Seeing the output of Hello World is still as excited as when I was learning C two years ago. The hhh
video said that the writing of the main function has not changed for thousands of years, which is too long...
Keyword
Completely lowercase letters
Identifier
The words after public class are identifiers (and variable names, method names), which cannot start with numbers and cannot be keywords.
Class name: capitalize the first letter of each word.
Variable: capitalize the first letter of each word, and capitalize the first letter of each word after it
Output statement
System.out.println("Hello,World");
It will automatically wrap, and can output strings, characters, integers, and floating-point numbers. There
can be empty strings but no empty characters . There is one and only one character. Chinese characters are accepted , but empty constants cannot be output.
double a=0.1;
float b=0.1f;
long c=2l;
F is added after the float variable, l is added after the long variable, and the
byte type is not required for double : Value range [-128, 127]
Data conversion
Small value range -> long value range ->
float
int -> String
System.out.println("A"+20);
Output: A20
When forced type conversion, the number after the decimal point is directly erased , and it will not be rounded. When
byte/short/char operation is first converted to int , the result of the operation is int, and the output is a number
Boolean type. No type conversion can occur. The
compound assignment operator contains coercion. Type conversion
Data calculation
The + operation of string is
the correspondence between characters and integers in concatenation operation (python) : ASCii / Unicode
comparison operations cannot be concatenated