| Grammar |
Description |
| Comments |
|
| // |
Single-line Comment |
| /*...*/ |
Multi-line comments |
| /**...*/ |
Document comments |
| Separator |
|
| ; |
Each Java statement must end with A; |
| {} |
Define a block of code |
| [] |
Used to access array elements 0-n |
| () |
Method definition, method invocation, operator |
| . |
Delimiter between a class/object and its members |
| Identifier |
|
|
Consists of letters, underscores (_), dollar characters ($), numbers, where numbers do not begin |
| Java keywords |
|
| Abstract |
Abstract |
| Assert |
|
| Boolean |
Boolean (can only be true or FALSE, other data types cannot be converted to Boolean types) |
| Break |
End Loop, etc. |
| Byte |
Integral type (1 bytes) |
| Case |
Branch statements |
| Catch |
|
| Char |
Character type (2) " |
| Class |
Class |
| Const |
Reserved words |
| Continue |
End this cycle |
| Default |
Default (interface default class definition) |
| Do |
Looping statements |
| Double |
Floating-point (8) |
| Else |
Judgment statement |
| Enum |
Enumeration |
| Extends |
A successor B (class A extends B) |
| Final |
|
| Finally |
|
| Float |
Floating-point (4) is defined with a number followed by F to indicate |
| For |
Looping statements |
| If |
Judgment statement |
| Goto |
Reserved words |
| Implements |
Implementing interfaces |
| Import |
Classes for importing Packages |
| instanceof |
(operator) to determine if the conversion can be successful |
| Int |
Integral type (4) |
| Interface |
Defining interfaces |
| Long |
Integer (8) is defined by the number followed by the L to indicate |
| Native |
Similar to an abstract approach, the difference is that the native method is usually implemented in C (will lose cross-platform functionality) |
| New |
Call constructor |
| Package |
Create package (first line) |
| Private |
Private |
| Protected |
|
| Public |
Total |
| Return |
End method |
| Short |
Integral type (2) |
| Static |
Static (class member) |
| Strictfp |
Make floating-point calculations more precise within the cosmetic range |
| Super |
Call the parent class overridden instance method | variable |
| Switch |
Branch statements |
| Synchronized |
|
| This |
Invokes the member of the current class (non-static adornment) |
| Throw |
|
| Throws |
|
| Transient |
|
| Try |
|
| void |
No return value |
| Volatile |
|
| While |
Looping statements |
| Automatic type conversion |
|
| BYTE---------long------double |
| CHAR-to-int |
| Forcing type conversions |
|
| (targetType) value |
Force the conversion of value to the TargetType type |
| Expression type auto-promotion |
|
|
All byte, short, char type will be promoted to int type |
|
The entire arithmetic expression data type is automatically promoted to the same type as the highest-level operand in the expression |
|
Two integers, even if not done, will get an integral type |
| Trinocular operator |
|
|
(expression)? If-true-statement:if-false-statement |
|
|
|
|
|
|