1.java Data types
Basic data: Numeric type (byte,short,int,long,float,double), Word 4, public access control
If the public access control is used before a member method or member variable name, the member can be accessed by all classes, regardless of whether the access class is in the same package as the class being accessed. Finally, we use a graph to summarize the permissions of the above access control.
Type (char), Boolean (Boolean)
Reference data types: Classes (Class), interfaces (interface), arrays
2. Data output
Byte,short,int,long--------------%d Int,long-----------------%x
Float,double---------------%f
Char---------------%c
String---------------%s
3. Shaping constants
An integer default of four bytes, if the value exceeds 4 bytes, must add L, otherwise error;
Long i = 1000000000000000000000l;//not plus l will error
4. Floating-point constants
A real number is a double type by default, and if you assign a double directly to float it will give an error, you must add f or force type conversion
float x = 2.2f; or float x = (float) 22;
5. Variable occupies storage space
Byte 1 bytes
Short 2 bytes
int 4 bytes
Long 8 bytes
Float 4 bytes
Double 8 bytes
Char 2 bytes
Boolean 1 bytes
6. You cannot force type conversions on a Boolean type
7. Class access control: Public, protect, default, private
1.Private access control
If the private access control is used before a member method or member variable name, the member can only be used inside the class;
2. Default Access control
If no access control is used before a member method or member variable name, we call this member the default (default), or a friend (friendly), or package type. For the default access control member, it can be accessed by other classes in the package.
3.protected access control
If the protected access control is used before a member method or member variable name, the member can be accessed by other classes in the same package or by subclasses in different packages.
4. Public access Control
If the public access control is used before a member method or member variable name , the member can be accessed by all classes. Whether the access class and the class being accessed are in the same package .
8. When an object is created, the member variable is automatically initialized to the value:
The first day of Java learning