Switch
The Code
The code for the fifth class of Java is as follows:
package switch; public class SwitcherCarReg { /** * @param args the command line arguments */ public static void main(String[] args) { /* A simple program used to demonstrate and allow * students to alter a basic switch construct */ String carPlate = "CE"; // String with fixed value /* The switch construct will then evaluate the value of the variable carPlate. There are various important components 1. The break 2. The default case */ switch(carPlate) { case ("C"): System.out.println("Cork Car"); break; case("CE"): System.out.println("Clare Car"); //break; case ("T"): case("TN"): case ("TS"): System.out.println("Tipperary Car"); default: System.out.println("Car is not from Munster"); }// End of switch }// End of main }// End of class