Java #29: How to Use A Switch Statement in Java

—————————Full Source Code————————

//Programmer: Akinwale Owi
//Company: Dagba Computers
//Program Purpose: Switch Statement Example in Java


* @author Akin

import java.util.Scanner;

public class DagbaComputerSample {

* @param args the command line arguments

public static void main(String[] args)
//Creating the Scanner we will read the user’s choice with
Scanner clientChoice = new Scanner(;

//Asking the user a question
System.out.println(“Welcome to my menu! Please enter choice below:”);
System.out.println(“Enter 1 for keyboard review”);
System.out.println(“Enter 2 for mouse review”);
System.out.println(“Enter 3 for monitor review”);
//Reading in their response
int client = clientChoice.nextInt();

switch (client)
case 1:
System.out.println(“Ours are comfortable”);
case 2:
System.out.println(“Fit your hand perfectly”);
case 3:
System.out.println(“Clear as day”);
}//end of main function

}//end of DagbaComputerSample Class

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s