We will explain a Switch statement is —
The syntax of switch case is :
Syntax:-switch()
{
case1:
statement()
break;
case2:
statement()
break;
default:
statement()
break;
}
Example:-
public class MyClass
{
public static void main(string[] arg)
{
int score=90;
switch(score)
{
Case 90:
System.out println(“Very good”);
break;
Case 60:
System.out println(“Good”);
break;
Case 40:
System.out println(“OK”);
break;
default:
System.out println(“The grade is not valid”);
}
}
}
0 Comments:
Post a Comment