A variable named
(1) What is variable: java variable is space to store data.
(2) variable naming rules: a: the number of (digital), word (letters), under (underscore), the US (dollar sign), person (the names of currency symbol) identifier composed. Note: Figures can not serve as the first letter. And you can not use java keywords
Second, comments
(1) The reason for using annotations: Annotations are an important means of communication between developers and program the reader's. After we wrote a large project, comments can help us to better benefit the old and the operation code.
(2) single-line comment: Input "//" comment before, behind the sign text will not be executed compiled. Note: Enter "//" before the code behind the code is not compiled a comment.
(3) Multi-line NOTE: As the name suggests to comment lines of code. Shortcuts: ctrl + shift + /.
(4) documentation comment: "/ * * /", the official API to generate help files of the same file.
Third, the data type
Note: String data type is a reference, not the basic data types
(1) level data types: the more the number of bits stored, the higher the level. details as follows:
char→int→long→float→double
byte→short→int→long→float→double
(2) data type conversion:
Automatic type conversions: from small to large to turn up automatically converted to data types such as:
byte b = 7; int i = b; b is automatically converted to type int.
Cast: for example, a small turn large cast:
int num = 768;byte by=num;byte by=(byte)num;
Run shown above, there will be data loss. Therefore, we must pay attention when in use.
Four, Scanner class
(1) trilogy
import java.util. * Scanner class introduced
Scanner input = new Scanner (System.in) objects to create Scanner
String name = input.next () method call next
(2) the use of
Fifth, operators
(1) Classification: arithmetic operators, relational operators, logic operators, bitwise operators, operator condition. Note: Bit operator is required to operate the digital conversion into a binary number.
(2) the operator precedence: writing the project, if we can not remember a priority, use (), because this is the most advanced.