wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes switch case Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "switch case" Watch "switch case" New topic
Author

switch case

Manoj Zachariah
Ranch Hand

Joined: Dec 08, 2003
Posts: 65
can i use string values in a switch statement
ex:

Vineela Devi
Ranch Hand

Joined: Dec 20, 2003
Posts: 191
Hai Manoj,
no, u cannot use string values in switch() construct coz the rule for
switch() is tht the variable u pass as argument to switch() must be compatible to int i.e. only byte, char, short and int should be passed as argument to switch() and long, float , double and any object reference should not be passed.

vineela
Maarten Vergouwen
Ranch Hand

Joined: Jan 12, 2004
Posts: 60
Note that you _can_ use a char, so in your example you could test for 'A', only you'd use single iso double quotes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: switch case