786snow
Programmer
- Nov 12, 2006
- 75
I keep geting this error
C:\irfan_java>javac switching.java
switching.java:8: incompatible types
found : java.lang.String
required: int
switch ( name )
^
1 error
*************
What am I doing wrong here?
*********************
class switching
{
public static void main(String[] args)
{
String name= "paul";
switch ( name )
{
case "paul":
System.out.println("name is paul");
break;
case "sam":
System.out.println("sam");
break;
default:
System.out.println("no name found");
}
}
}
C:\irfan_java>javac switching.java
switching.java:8: incompatible types
found : java.lang.String
required: int
switch ( name )
^
1 error
*************
What am I doing wrong here?
*********************
class switching
{
public static void main(String[] args)
{
String name= "paul";
switch ( name )
{
case "paul":
System.out.println("name is paul");
break;
case "sam":
System.out.println("sam");
break;
default:
System.out.println("no name found");
}
}
}