Sponsered Links
Categories
Sponsered Links

Java Control Statement Example

 

This is a simple Core Java Control Statement Example.

int n = 10;

if(n%2 = = 0){

     System.out.println("This is even number");

}

---------------------------------------------------------------------

int n = 11;

if(n%2 = = 0){

     System.out.println("This is even number");

}

else{

     System.out.println("This is not even number");

}

-----------------------------------------------------------------------

int a = 2;

switch (a) {
       case 1:
            System.out.println("Java");
            break;
       case 2:
           System.out.println("PHP");
           break;
}

----------------------------------------------------------------------

int i = 1;

while (i <= 10){

    System.out.println("Num " + i);

    i++;

}

---------------------------------------------------------------------

int i = 1;

do{

    System.out.println("Num: " + i);

     i++;

}while(i <= 10);

--------------------------------------------------------------------

for (int num = 1; num <= 10; num++){

      System.out.println("Num: " + num);

}

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved