0. Comments
// --Single-line comments.
/* */ --Mulitiline comments.
/** --Documention comments.
1. Identifiers
a. keyWord
b. varName
c. className
2. Data Types
Tips:
a. Long type need a “L” at the end of expression.
b. Float type need a “F” at the end of expression.
c. String is a class , not a keyWord.
Expands:
a. Base
- Binary starts with 0b.
- Octal starts with 0.
- Hex starts with 0x.
b. Do not use floating-points for comparing.
c. Java can convert character to Unicode.
3. Type Convert
a. Forced convert
( Type ) [varName]
When capacity from high to low
b. Auto convert
When capacity from low to high
c. Tips
①Do not convert booleans.
②Forced convert maybe occur a accuracy problem.
③When the number is too large, the underline can be used for segmentation.
4. Vars and Consts
a. Scopes
①Class var: Outside the method , need “static” to state.
②Instance var: Outside the method , state directly.( I do not know the differences between them temporarily ( _ _)ノ|)
③Local var: Inside the method , must state and initialize.
b. Define a const
final [CONST_NAME] = [Value]
b. Naming conventions
①All names need to be clear.
②Var names use camel case ( uppercasing the first letter of each word)
③Const names need to uppercase every letter.
5. Calc
a. Priority of data types
double > long > int
b. Self-added operator
a++: Assign first and then increase.
++a: Increase first and the assign.
c. Logic calculations
①&&(Short circuit AND): If the first value is 0 , do not judge the second value and then output 0.
②||(Short circuit OR): If the first value is 1 , do not judge the second value and then output 1.
③!(NOT): Convert 1 to 0 and also 0 to 1.
④&(Bit AND): If the input data type is int , this is a bit operator ,It will convert the values on both sides into binary first , and then carry out logical calculation according to each bit. Else this is a logical operator , it will judge both values and output.
⑤I(Bit OR): The same as mentioned above.
⑥^(XOR): The same is zero, and the different is one.
⑦~(Reverse): When use as a logical operator , it’s function as same as NOT. When use as a bit operator , it can reverse according to each bit.
d. String connector
"+"
From left to right , if there is a string , execute string connection automatically.
e. Ternary operator
public class Hello {
public static void main(String[] args) {
int s=98;
String t = s < 100 ? "junk" : "new bee" ;
System.out.println(t);
}
}
6. Package
- The essence of package is a folder.
- Use “import” to import external packages.
- Use javadoc to create docs of a java program(include structure and so on) , the method is on below
javadoc -encoding UTF-8 -charset UTF-8
This day is finished , if you have any problem , welcome to question me.ヾ(•ω•`)o