"Java Fundamentals" "Lesson Three" expressions, control structures

Source: Internet
Author: User

Look at the agile development process for two days, am I an agile blogger? Haha o (∩_∩) o

1  Packagea.b;2 3  Public classthree4 {5     Static voidExpression ()6     {7System.out.println ("One, basic expression of learning");8         9         //Mathematical ExpressionsTenSYSTEM.OUT.PRINTLN (1 + 2);//addition OneSystem.out.println (4-3.2);//Subtraction ASYSTEM.OUT.PRINTLN (7 * 1.5);//multiplication -System.out.println (29/7);//Division -System.out.println (29%7);//Seeking Redundancy the          -         //Relational Expressions -System.out.println (6 > 4.2);//Greater than -SYSTEM.OUT.PRINTLN (3.4 >= 3.4);//greater than or equal +SYSTEM.OUT.PRINTLN (1.5 < 9);//less than -SYSTEM.OUT.PRINTLN (6 <= 1);//less than or equal +SYSTEM.OUT.PRINTLN (2 = = 2);//equals ASYSTEM.OUT.PRINTLN (2! = 2);//Not equal to at  -         /*     - some of the other expressions - true && false and - (3 > 1) | | (2 = = 1) or - !true not in   - //bit arithmetic to & and +         | or - ^ xor the ~ Not * 5 << 3 0b101 left shift 3 bits $ 6 >> 1 0b110 right shift 1 bitPanax Notoginseng  - m++ variable m plus 1 the n--variable n minus 1 + condition? x1:x2 condition is a Boolean value. According to condition, take the value of X1 or X2 A         */ the     } +      -     Static voidcontrolstructure () $     { $System.out.println ("Second, learning control structure"); -          -         intA = 0; the          -         //SELECT statementWuyi         if(A = = 1)  the         { -SYSTEM.OUT.PRINTLN ("Learn if statement if"); Wu         } -         Else if(A = = 0)  About         { $SYSTEM.OUT.PRINTLN ("Learn if statement else if"); -         } -         Else  -         { ASYSTEM.OUT.PRINTLN ("Learn if statement else")); +         } the          -         //Looping Statements $          while(a<3) the         {     theSystem.out.println ("Learning while statement" +a); thea++; the         } -          in          Do the         { theSystem.out.println ("Learning do While statement" +a); Abouta++; the} while(a<6); the          the         //use break to jump out of a loop, use continue to go directly to the next loop +          for(inti = 0; I < 5; i++) -         { the             if(i = = 1)Bayi             { the                 Continue;  the             } -             if(i = = 4 )  -             { the                  Break; the             } theSYSTEM.OUT.PRINTLN ("Learn for statement" +i); the         } -          the         //SELECT statement the         Charc = ' B '; the         Switch(c)94         { the          Case' A ': System.out.println ("Learning swithch statement" +c); Break; the          Case' B ': System.out.println ("Learning swithch statement" +c); Break; the          Case' C ': System.out.println ("Learning swithch statement" +c); Break;98         default: System.out.println ("Learning swithch statement default"); Break; About         } -     }101     102     103      Public Static voidMain (string[] args)104     { the         //learn the basic expressions106 Expression ();107         108         //Learning Control Structure109 controlstructure (); the     }111  the}


The results of the operation are as follows:

First, learning the basic expression 30.799999999999999810.541truetruetruefalsetruefalse Ii. learning control Structure Learning if statement else if Learning While Statement 0 learning while Statement 1 learning while Statement 2 learning Do While Statement 3 learning Do While Statement 4 learning Do While Statement 5 learning a For statement 0 learning for a For statements 2 learning for Statement 3 Learning SWITHCH Statement B

"Java Fundamentals" "Lesson Three" expressions, control structures

Related Article

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.