Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is wrong with this switch statment

Status
Not open for further replies.

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");
}



}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top