1. Naming rules for identifiers
Letters, underscores, numbers, dollar signs ($) are made up of these four parts.
Identifier = First Letter + other
Initial letter: letter, underscore, dollar sign ($)
Other: Letters, underscores, numbers, dollar signs ($)
Attention:
1, the first letter can not be a number
2. Identifiers cannot be keywords
3, the Java language is strictly case-sensitive, such as: $name $Name represents two different identifiers
2. Notes for Java programs: single-line comment (//), multiline comment (/**/), document (DOC) Comment
Single-line comment: Typically used to describe each row of code
Multiline comment: Typically used to interpret each piece of code, a method, a source file
Documentation notes:
Select the project for which you want to generate Doc comments, right-click->export->java->javadoc-> finish
Attention:
1. Multiline comments cannot nest multiple lines of comments
2, single-line comments can be nested multiple lines of comments, no practical significance
3, do not light easy to add a single line of comments in a multiline comment
3, Java floating-point type by default is double, if you need to add a float f
such as: 3.4f (float type)
3.4 (double type)
Example: Double num=0.2 (no error)
Float num=0.2 (error will occur, you need to add suffix F or f)
After modification:
Float num=0.2f
Float num=0.2f
float num= (float) 0.2
4, low precision can be converted to high precision, but high precision cannot be converted to low precision
For example:
Double a=10;
Double c=a; (no error, because low precision can be converted to high precision)
int d=a; (error, because high precision cannot be converted to low precision)
5, a=i++ (first assignment and then self-increment 1)
b=i--(first assignment and then minus 1)
C=++i (self-increment 1 and then assign value)
D=--i (self-subtract 1 and then assign value)
6, MyEclipse shortcut key:
1, there is an error, you can press F2 to make the error copy
2. The shortcut key for copying code lines is: ctrl+alt+ up and DOWN ARROW keys
3. Delete a row's shortcut key: Ctrl+d
4. Shortcut key for formatting code: CTRL+SHIFT+F
5. Move the shortcut key for a line of code: ALT + up and DOWN ARROW keys
6. Display the number of rows in Java: Right-click-->show line Numbers
7, one-time comment multi-line shortcut key: Ctrl + "/"
7, Scanner common methods
Scanner inform = new Scanner (system.in);
| Method |
Description |
| Inform. Next () |
Receive when typing a string |
| Inform.nextboolean () |
Receive when typing a Boolean type |
| Inform.nextfloat () |
Type single-precision floating-point type when receiving |
| Inform.nextdouble () |
Receive when you type double-precision floating-point |
| Inform.nextint () |
Receive when typing an integral type |
Java the next day--identifier naming rules, Java Knowledge, use of shortcut keys, scanner to get the value of common methods