A, java modifiers and usage scenarios
Modifier is used to define the class, method or variable access rights, divided into two categories:
-
Access modifiers:
Whether defined classes, properties, methods in other parts of the program can be accessed and invoked.
private<default<protect<public
-
Non-access modifiers used to modify or assist:
For example static, final, abstract, synchronize, etc.
The main Remember:
-
External class modifiers: public or default
-
Method, property modifiers: private, default, protected, public
-
public disclosure of the externally visible
-
protected package and subclasses visible
-
Internal private class only visible
-
Modifiers | The current class | The same intracapsular | Different subclasses package | Different classes package nonsubtyped |
---|---|---|---|---|
public | AND | AND | AND | AND |
protected | AND | AND | AND | N |
default | AND | AND | N | N |
private | AND | N | N | N |
Two, JAVA built-in data types Introduction
-
Eight basic types of data (each data required to store the data from the application space of the computer)
-
byte
-
8th
-
Maximum 127, minimum -128
-
Save space, occupied a quarter of an int
-
Default: 0
-
-
short
-
# 16
-
Maximum 32767, minimum -32768
-
One-half of type int
-
Default: 0
-
-
int
-
# 32
-
Min -2147483648, maximum 2147483647
-
The default integer type is int
-
Default: 0
-
-
long
-
# 64
-
Min -9223372036854774808, maximum 9223372036854774807
-
Default value: 0L
-
-
float
-
Single precision 32-bit
-
0.0f
-
-
-
64-bit double precision
-
The default double floating-point type
-
The default value 0.0d
-
-
boolean
-
One
-
true or false
-
The default is false
-
-
char
-
16-bit Unicode characters, two bytes represent a character
-
The minimum \ u0000 that is 0, the biggest \ ufff namely 65535
-
-
Type Conversion
-
double>float>long>int>short>byte
-
Small turn big can be directly converted, while descending the need to cast, there will be loss of accuracy
-
-
-
Reference data types: array of Class objects or reference data types are created
-