2.1 identifier and Keyword 2.1.1 identifier
Identifier: A valid sequence of characters used to flag the class name, variable name, method name, type name, array name, and file name is called an identifier. Simply put, an identifier is a name.
Java syntax rules for identifiers
Identifiers consist of letters, underscores, dollar signs, and numbers, and are not limited in length.
The first character of a marker cannot be a numeric character.
Identifier cannot be a keyword
The marker cannot be true,false and null (although True,false and null are not Java keywords)
Letters in identifiers are case-sensitive, and hello and hello are different glyphs
2.1.2 Keywords
Keywords are words that have been given a particular meaning in the Java language. You cannot use keywords as identifiers. Here are 50 keywords for Java
Abstract, Assert, Boolean, break, Byte, case, catch, char, class, const, continue, default, do, double, else, enum, extends, Final, finally, float, for, Goto, if, implements, import, instanceof, int, interface, long, native, new, package, private, Protect, public, return, short, static, STRICTFP, super, switch, synchronized, this, throws, Transitent, try, void, volatile , while
2.2 Basic data Type 2.2.1 Logical type
Boolean:true/false
2.2.2 Integer type
Serial number |
Type |
Range |
1 |
Int |
-2 of the 31-time Square of 31 square-1 |
2 |
Byte |
-2 of the 7-time Square of 7 square-1 |
3 |
Short |
-2 of the 15-time Square of 15 square-1 |
4 |
Long |
-2 of the 63-time Square of 63 square-1 |
2.2.3 Character types
Escape characters:
Serial number |
Character |
Meaning |
1 |
\ n |
Line break |
2 |
\b |
Backspace |
3 |
\ t |
Horizontal tabulation |
4 |
\‘ |
Single quotation marks |
5 |
\" |
Double quotes |
6 |
\\ |
Back slash |
2.2.4 Floating-point types
Serial number |
Character |
Meaning |
1 |
Float |
A constant must be followed by F or F |
2 |
Double |
Constants can be followed by D or D |
2.2.5 Conversion of basic data types
When the value of a low-level variable is assigned to a variable of high level, the system automatically completes the conversion of the data type
When a variable of high level is assigned to a variable of low level, the display type conversion operation must be used
3 Entering output data from a named row 2.3.1 entering basic type data
Scanner reader = new Scanner (system.in);
Reader.nextdouble ();
2.3.2 Output Basic type data
Serial number |
Describe |
Description |
1 |
%d |
output int type data |
2 |
%c |
Output Char type data |
3 |
%f |
Output floating-point data, the fractional part retains up to 6 bits |
4 |
%s |
Output string data |
5 |
%md |
output int data, in M-column |
6 |
%m.nf |
Output floating-point data in M-column, decimal point reserved n-bit |
2.4 Array 2.4.1 Declaration array
float boy[];
Char cat[][];
2.4.2 Creating an array
float boy[] = new FLOAT[4];
int mytwo[][] = new int [3][4];
Use of 2.4.4 length for 2.4.3 array elements
float a[]=new float[12];
Initialization of the 2.4.5 array
Float boy[] = {21.3f,23.89f};
2.4.6 references to arrays
Array is a reference type
2.4.7 Presentation format
Arrays.tostring (a);
2.4.8 Copying an array
(1) Arraycopy method
(2) copyof and Copyofrange
2.4.9 sorting and two-point search
Sort
2.5 Enum Types
Enum season{
Spring, summer, autumn, winter
}
2 Primitive type arrays and enumeration types--Re-picking Java