Java Switch Case Statements

One of the alternative to if else statements is Switch Statment. Just like its names, its act like a switch based on the case parameter. The syntax is easy to read and are useful complex case. 

Switch (text)
{
   Case "start":
   System.out.println("start machine");
   Break;

   Case "stop":
    System.out.println("stop machine");
    Break;

    Default:
    System.out.println("invalid command");

}


Java Switch Case Statements Java Switch Case Statements Reviewed by Admin on 9:32 AM Rating: 5

No comments:

Powered by Blogger.