After more than a year of graduation, I found that my growth lags far behind those who are struggling, even though I am also struggling. But I don't have any technology that I can use. Although I like programming, I have never mastered a technology. Now I should think deeply about my life. So last week, I decided to give up the C language and learn Java, and then learn Android after learning Java.
This is my first study note on java. Most of the content experts are very inconspicuous technology, but it is very valuable to me! Hope I can stick to it!
Java is purely self-taught and used in combination with video learning.
I will not discuss the history of Java. I will directly record some notes that I think are important.
1. Four types of Java data:
- Logical type: Boolean
- Integer type: byte, short, long, int
- Floating point type: float, double
- Character Type: Char
2. Basic syntax
Define variables -- initialize -- assign values
Syntax composition: Data Type + variable name;
For example: int x = 2; (thisCodeInclude: defines the variable X as the int Integer type and assigns it a value of 2.
2.1 conversion of data types: forced conversion:ProgramCannot be forcibly converted from double to int, but can be converted from int to double.
For example:
Int A = 1;
Double B = 2.3;
A = B; in this case, the program reports an error because a is of the int type and B is of the double type.
However, it is okay to forcibly convert a = (INT) B.
3. Operators and expressions
3.1 Arithmetic Operators: +,-, *,/, %, + =,-=, % =
3.2 Relational operators: = ,! =, <,>, <=,> =
3.3 logical operators: &, | ,! (Respectively, or, not)
4. Three major control processes
4.1 sequence: The program is executed from top to bottom.
4.2 Branch
4.2.1 single branch
If(Conditional expression) {statement ;}
4.2.2 dual Branch
If(Conditional expression) {statement ;}Else{Statement ;}
4.2.3 multiple branches
If (conditional expression 1) {statement ;} else If (condition expression 2) {statement ;} else If (condition expression 3) {statement ;} else { statement ;}
Switch(Conditional expression ){CaseConstant 1: statement;Break;CaseConstant 2: statement;Break;CaseConstant 3: statement;Break;}
4.3 cycles
4.3.1for Loop
For(Cyclic value assignment; cyclic condition; cyclic duration) {statement}
4.3.2while loop (here the loop isFirst judge and then execute the statement)
While(Cyclic condition) {statement ;}
4.3.3do WHILE LOOP
Do{Statement ;}While(Cyclic condition );