using switch in strings
Posted
by xtemer
on Stack Overflow
See other posts from Stack Overflow
or by xtemer
Published on 2010-05-29T09:55:26Z
Indexed on
2010/05/29
10:02 UTC
Read the original article
Hit count: 305
java
|switch-statement
guys me trying to use switch in strings by first coverting string into char and then apply switch but still didnt done it....here is my code..help me out..
import javax.swing.*;
import java.io.*;
class HappyBirthday {
public static void main(String[] args) throws IOException
{
String Month;
char[] Months = Month.toCharArray();
BufferedReader dataIn= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter your month.");
Month = JOptionPane.showInputDialog("enter month");
String month1={"January","feb"};
char[] month2 = month1.toCharArray();
// String s=month1.equals(Month);
//System.out.print(month2Array[0]);
switch (month2) {
case 0:
System.out.println("kool");
break;
case 1:
System.out.println("not kool");
break;
default:
}}}
/** if (month1[1].equals(Month))
System.out.println("kool");
else if(month1[0].equals(Month))
System.out.println("kooooooooooooool");
else
System.out.println("Big kooooool"); **/
© Stack Overflow or respective owner