If else and nested loop

Source: Internet
Author: User

Package com. xml. test;

Public class testc {

/**
* If else/If else if difference
* If (){
* If the condition is true, the execution is performed.
*} Else (){
* If the condition is not true, run this command.
*}
*------------------------------------------------------------------------------
* If (){
* If the condition is true, the execution is performed.
*} Else if (){
* If the if statement is not true, the else statement is executed if it is true.
*} Else if (){
* If the preceding else is not true, the first else if is executed. If the else if condition is true, the next else if statement is not executed.
*} Else {
* If none of the above if or else if conditions are true, the last else block is executed.
*}
*/
Public static void main (string [] ARGs ){
Int A = 100;
If (A & gt; 1000 ){
System. Out. println ("Great, I can buy Audi Q7 ");
} Else if (a> 500 ){
System. Out. println ("oh, I can buy Audi Volvo cx90 ");
} Else if (a> 95 ){
System. Out. println ("not bad, I also like ");
} Else if (a> 90 ){
System. Out. println (" ");
} Else {
System. Out. println ("implement the house first ");
}
Circlecontroler ();
System. Out. println ("I am back to main ...........");
}
 
/**
* Difference between break return and continue FS
* The Break force interrupts the cycle, and the judgment statements after the break in the loop body are not judged, directly jumping out of the loop in Vitro
* When break is used in a series of nested loops, it will only terminate the innermost loop.
*
* When the continue statement is executed, the loop will skip the next part and return directly to the starting point of the loop for judgment and operation (A <10; A ++)
*
* When the return statement is executed, all nested loops in the method are skipped and the place where the method is called is directly redirected to continue execution.
**/
Public static void circlecontroler (){
For (INT I = 0; I <2; I ++ ){
For (int A = 0; A <10; A ++ ){
System. Out. println ("starts ......" + );
If (A = 5 ){
Return;
}
}
System. Out. println ("jumping out of the for small loop .............");
}
System. Out. println ("jumping out of the for loop .............");
}

}

 

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.