First Java study note

Source: Internet
Author: User

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:

    1. Logical type: Boolean
    2. Integer type: byte, short, long, int
    3. Floating point type: float, double
    4. 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 );

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.