Java programming thought note Fourth chapter control the execution process

Source: Internet
Author: User
Tags terminates

1.true and False

1.1 If--else If--else, while, Do--while uses the true and false of conditional expressions to determine the execution path.

1.2 Java does not allow numbers to be judged as true or FALSE, C and C + + may not be 0.

2.math.random ()
    • Produces a double value [0, 1] including 0, excluding 1.
3.foreach syntax
    • If the for (float x:f) {} f is an array, the method of returning an array can be used with the foreach
4.return

    • Return causes the current method to exit and return a value.
    • Any method except the constructor has a return value type such as void Fun (), a String fun (), a void fun (), does not need to write a return, the default is return, the other method must have a return value (or the expression produces a value)
5.break and Continue
    • Break terminates the current owning layer loop and exits the loop, continue terminates the current owning layer loop and enters the next loop.
5.1 Tags: use when you want to jump out of nested loops
ContinueLeab;//jump to the loop where the label is located, and notice that I does not increase in the inner loop ,//Break Leab; jump out of the loop where the label is, no longer loops, and the inner layer I will not increaseLeab://No other code can be added between the label and the iteration body         for(j = 0; J < 5; J + +) {System.out.println (Outside);  for(; i < ten; i++) {                if(i = = 6) {                                        ContinueLeab; //Break Leab;} System.out.println ("Nei"); }        }

6. Switch (value)
Switch //         Case 1:SYSTEM.OUT.PRINTLN (1);  Break ;          Case 2:system.out.println (1);          Case ' A ': System.out.println (97);  Break // Char ' A ' is automatically converted to ASCII value        }

Java programming thought note Fourth chapter control the execution process

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.