First, the identifier (naming)
Class names, variable names and method names are called tags, note the following issues:
- The first character must start with a letter (AZ, az), the dollar sign ($), or underscore
- The content may be composed of letters (AZ or az), any combination of characters dollar sign ($), underscore (_) or digital
- Keywords can not be used as identifiers
- Case Sensitive
habit:
- (1) to comply with the identifier semantic information.
- (2) the package name all lower case letters.
- (3) the class name of each word capitalized, other lowercase, such as: TarenaStudent.
- (4) variables and methods: the first word lowercase, beginning from the second word capitalized, such as: tarenaStudent.
- (5) Constant: all capital letters, with each word between connection _.
Common escape characters:
"\ B" (backspace) "\ F" (FF) "\ n-" (line feed) '\ R & lt " (carriage return) " \ T " (horizontal tab (to the next tab position)) " \ '' (single quote) "\" " (double quote) " \\ " (backslash)
Second, variable
Java variables are the following:
- Local variables
- Class variables (static variables)
- Member variables (non-static variables)
Third, the basic type
The eight basic types of Java byte by byte :( points)
boolean | Boolean | 1 byte |
byte | Byte type | 1 byte |
char | Character Types | 2 bytes |
short | Short integer | 2 bytes |
int | Integer | 4 bytes |
float | Float (single-precision) | 4 bytes |
long | Long integer | 8 bytes |
double | Double type | 8 bytes |
Java is the default integer type int, if you want to define a long, will have to add the value in the L or l
The default type is a floating point double precision floating point, if you want to define float, will have to add the value in the back or F f
A byte is equal to 8, a number of bytes equal to 256. 2 ^ 8
A letter or digit occupies one byte
A character 2 bytes