public String[10] name;
in Java is public char = 'a';
mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
Hi jackmaverick
Not being able to do a switch on Strings is a well known shortcoming of Java and (at last!) its fixed in Java 7 - which will be out later this year. You can switch on a single char because a Java char is a numeric type (16 bit integer) - but not on an array of them.
But either way, if you want to do a switch on a String then you probably should be using an enum anyway - your set of valid Strings must be fixed and known at compile time, so an enum would be the right construct to use and (bet you saw this coming) you can switch on an enum.
Have a look at enums and if you have any questions come back here..
JamesCherrill
Posting Genius
6,370 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073