Home
Tutorials
Core Java
Introduction To Java
Java Evolution
Overview of Java
Constants, Variables and Data Types
Java Operators
Branching Statements
Looping Statements
Classes, Objects and Methods
Inheritance
Array, String and Vectors
Java Interfaces
Java Packages
Applet Programming
Graphics Programming
Advanced Java
Java AWT
Java Event Handling
Java File Handling
Java MultiThreading
Java Swing-I
Java Swing-II
Exception Handling
Socket Programming
Java Database
Java RMI
Java Servlets
Java Beans
Programms
Projects
Downloads
Contact
Java Programming
!doctype>
Switch Statement
//The Switch Statement import java.io.*; class SwitchStatement { public static void main(String args[]) throws Exception { char ch; System.out.print("\n\tA. Red"); System.out.print("\n\tB. Blue"); System.out.print("\n\tC. Yellow"); System.out.print("\n\tEnter Your Choice (A-C) :\t"); ch = (char) System.in.read(); switch(ch) { case 'A': { System.out.print("\n\tYour Choice is Red\n\n"); break; } case 'B': { System.out.print("\n\tYour Choice is Blue\n\n"); break; } case 'C': { System.out.print("\n\tYour Choice is Yellow\n\n"); break; } default: { System.out.print("\n\tYour Choide is Wrong...\n\n"); break; } } } }
Output of "SwitchStatement.java"
Read more »
Download Complete Source Code
No comments:
Post a Comment
No comments:
Post a Comment