Thursday, March 12, 2015

Switch Statement in a java pgm



Switch Statement    

public class SwitchStatementExample
{
public static void main(String[] args)
{
 switch(expression)
{
 break;
 case value2:
 default:
             break;
 }
for(int i=0; i <= 3 ; i++)
{
switch(i)
{
case 0:
System.out.println("i is 0");
break;
case 1:
System.out.println("i is 1");
break;
case 2:
System.out.println("i is 2");
break;
default:
System.out.println("i is greater than 2");
      }
   }
  }
}

No comments:

Post a Comment