Answer to Question #253595 in Java | JSP | JSF for Sara

Question #253595

Rewrite the following program using Switch:

if (x == 1) {

system.out.println("x is 1");

}

else if (x == 2) {

system.out.println("x is 2");

}

else {

system.out.println( "value of x unknown"); }



1
Expert's answer
2021-10-19T10:52:59-0400
switch(x)
{
    case 1:
        System.out.println("x is 1");
        break;
    case 2:
        System.out.println("x is 2");
        break;
    default:
        System.out.println("value of x unknown");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS