a java identifier and a keyword
1. Identifiers
Function: A valid sequence of characters used to identify the class name, variable name, method name, type name, array name, and file name.
Composition rule: consists of a letter, an underscore, a dollar sign, and a number, and the first character cannot be a numeric character. Note: The letters in the identifiers are case-sensitive , and boy and boy are different identifiers.
2. Keywords
Some words in the Java language are given certain meanings and cannot be used as names. The keywords are: abstract, Boolean, break, Byte, case, Catch, class, continue, do, double, else, enum, extends, false, find, finally, Float, for, implements, import, instanceof, int, interface, long, native, new, NULL, package, private, protected, public, Return, short, static, super, switch, synchronized, this, throw, true, try, void, while.
Two basic data types for Java
1. Logical type
Constant: True, False
Variables: Use the keyword Boolean to define logical variables, such as: Boolean x; Boolean Tom_12; You can also define several variables at once, such as: Boolean X,tom,jiafei; assign values when defining variables, such as: Boolean S=true,tom=false,jiafei;
2. Integer type
Integer types include: int, Byte, short, and long.
(1) INT type
Use the keyword int to define an int type integer variable. for type int variables, memory allocates 4 bytes (byte), 1 bytes consist of 8 bits (bit) and 4 bytes is 32 bits. Bit has two states, each with 0, one to represent.
(2) Byte type
Use the keyword byte to define a byte type integer variable, you can define a few at a time, you can also assign the initial value, such as: Byte m=-12,deep=28,speed=98; note: For byte variables, memory is allocated to 1 bytes, accounting for 8 bits.
(3) Short type
Use the keyword short to define a short integer variable, you can define a few at a time, you can also assign the initial value, such as: Short X=12,tom=123,jiafei, pretty = 9876; Note: For short variables, memory allocates 2 bytes, accounting for 16 bits.
(4) long type
Use the keyword long to define a long integer variable, you can define a few at a time, you can also assign the initial value, such as: Long x=12,tom=1234; note: For long variables, memory is allocated 8 bytes, accounting for 64 bits.
Learn Java Trivia "1" every day.