Java Foundation Composition:
keywords--identifiers--annotations--Constants & Variables--operators--statements--functions--arrays
keyword features: letters are all lowercase
Eg: basic data type: int byte long short float double
Character type: Char
Boolean: Boolean (True/false)
Reference data type: class interface void
Process Control: if () {}else{}
Switch () {
Case:
Break
Defualt:
}
Loop while doing () while for
Break jumps out continue continue return returns
Access rights: Private, public, protected
Defined:
Abstract final static synchronized (synchronous) enum (enum)
Extends implements
New This super instanceof (Judge object type)
Exception handling:
Try Catch finally
Throw (thrown by instantiation of an exception in a program)
Throws (identifies method throw exception)
Package: Package Import
Other: Native (local)
STRICTFP (Strict float point (exact floating-point))
Transient (variable modifier, which declares an instance variable that is not serialized when the object is serialized)
Volatile (type modifier, used to modify variables that are accessed and modified by different threads)
ASSERT (assertion, which can be considered a high-level form of exception handling, is used to capture the assumptions we make in our code)
identifiers
Some of the names that are customized in the program are made up of uppercase and lowercase [a-za-z], numbers [0-9], underscores [_], special characters [$].
Comments: Single-multirow-document comments
(Single-line comment)
/*
(Multiline comment)
*/
/**
(Document comment)
@author author
@version version number
*/
Constants
Immutable values
Variable
Storage of uncertain data, that is, the need to open up a space in memory
1. Initialization of variables:
(1) Java variables defined in the method are not automatically initialized and must be initialized before it can be used.
(2) variables defined in the class are automatically initialized.
Operator
+-*/% + +--+ = = (a+=4>>a=a+4) = (opposite) > <= ...
& with | or ^ xor or (True^true = False True^false = True opposite =true same =false)
。 Non-&& short circuit and | | Short-circuit or (when the left is true, the right does not operate because the result must be true to the left of false, right to participate in the operation.) )
The
* bitwise operator is the operator of a binary operation, and "bit" is the binary bit, the fastest operation, but the limit is based on 2. << Left 3<<2 = 3*2^2=12
>> right Shift 3>>1 = 3/2^1 = 1
>>> unsigned right shift 3>>1 = 3/2^ 1 = 1
& and Operations 6 & 3 = 2
| or operation 6 | 3 = 7
^ Xor/op 6 ^ 3 = 5
~ anti-code ~6 =-7
* ternary operator:
(conditional expression) 。 Expression 1: expression 2; => must have a result
(1) If the condition is true, the result of the operation is an expression 1;
(2) If the condition is false, the result of the operation is the expression 2;