1, Java Keywords:
1.1 Package Related:
Package : Package; Import : import the package;
1.2 access modifier :
public (public access modifier): it is declared as public classes, methods, constructor (the constructor or call) and the interface can be any other type of access;
protected (protected access modifier): child and parent class in the same package: is declared as protected variables, methods and constructors can be any type of access to the same packet;
Child and parent class is not in the same package: in a subclass, sub-class instance can be accessed from the parent class inherited peotected method, not the parent class instance access protected method;
private (Private access specifier): is declared as private variables, methods and constructors only allow access to this class and classes and interfaces instinct declared private ;
default (default access operator - without using any key): use the default access method and variable declarations, for the classes in the same package are visible;
Access level table
private | default | prtected | public | |
The same class | ✔ | ✔ | ✔ | ✔ |
The same package | ✔ | ✔ | ✔ | |
Subclass | ✔ | ✔ | ||
Within the scope of the global | ✔ |
1.3 class modifiers:
public : public class as the class declaration, any class may be accessed, a program of the main class must be public;
class : Modified class name;
abstract : define the class as an abstract class,
Final : The final will be declared as a class, that they can not be inherited;
the extends : a parent class inheritance;
interface : used to define the interface;
the implements : implements the interface;
strictfp : It is used to ensure the accuracy of floating-point operations;
1.4 Method modifiers:
static : the static modification method is static;
new new : create an object class;
the synchronized : controlling a thread synchronization;
1.5 Variable modifiers:
final : the final modified variable is the final amount can not be changed;
1.4 Basic Data Type:
int : Integer; Long : long integer; Short : Short Integer; Double : double precision floating point; a float : single precision floating; char : character; byte : byte; Boolean : Boolean;
1.6 program control (flow control):
if else; for;while; do while; switch; continue;instanceof; return;break;
1.7 Exception Handling:
catche Tyr : catch exceptions; the throw : throw an exception; throws : custom exception;
1.10 reserved keyword:
goto; const;
2, the identifier
2.1 identifier rules:
- Identified by characters, numbers, down the line and $ composition;
- You can not start with a number;
- Case sensitive;
- Of any length;
2.2 naming convention:
Package names | Class names and interfaces | Variable and function names | Constant name |
More than one word all lowercase; For example: com.up |
Multiple words, by hump nomenclature; For example: ComUp |
Multiple words, the first word lowercase, Other words capitalized; For example: comUpLooking |
Multiple words, all caps, Decline connecting line; For example: COM_UP |