I am a new programmer in Java and while programming I faced the following problem. I am trying to use switch statement on String but it gives compilation error. If any one suggest me how to use String in switch-case statement , it will be helpful to me.
niamul
0
Newbie Poster
Recommended Answers
Jump to PostYou don't need the switch. And you cover only String with letters 'a' to 'z'. For a better approach:
…String string2 = ""; char char1; for (int x = 0; x < input.length; x++){ char1 = input.charAt(x); int i = char1; string2 += i; } return string2;
Jump to PostSorry if you felt the post was negative. If you're here to learn something, I hope you learned something from it, such as a little taste of how a switch works and why this sort of thing simply can't work, considering what a switch actually is. To the compiler, it's …
Jump to PostHi all, one of you guys answered the question in page 2, but everyone ignored it :P Here is an exemple of what he was saying. You can't technically switch on String
you do know that Java 7 was released, and in Java 7 it ís possible to use a …
Jump to PostI agree that java 1.7 will be released. It's on beta now.
Wrong. Java 7 was fully released and made generally available July 28th 2011
Java 7 is the current release version.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-429209.html
Jump to PostActually, the new OS X does not come with Java installed, and Apple is, as far as I know, pushing Java development and maintenance off to the OpenJDK. Java on the mac is not a sure thing, not that it ever was very solid.
Honestly, I think Java 7 …
All 43 Replies
jwenting
1,889
duckman
Team Colleague
paradox814
1
Posting Whiz
niamul
0
Newbie Poster
jwenting
1,889
duckman
Team Colleague
cyberowl
0
Newbie Poster
jwenting
1,889
duckman
Team Colleague
cyberowl
0
Newbie Poster
Fhernd
commented:
It is clear.
+0
jwenting
1,889
duckman
Team Colleague
cyberowl
0
Newbie Poster
jwenting
1,889
duckman
Team Colleague
rLh
0
Newbie Poster
Ficke
0
Newbie Poster
staneja
0
Junior Poster in Training
manojdesai
0
Newbie Poster
Cudmore
9
Junior Poster in Training
jwenting
1,889
duckman
Team Colleague
nnprasad2000
0
Newbie Poster
Boyett Martinet
0
Newbie Poster
Boyett Martinet
0
Newbie Poster
BestJewSinceJC
700
Posting Maven
rameshrokz
0
Newbie Poster
pranalib
0
Newbie Poster
sadaf Nasim
0
Newbie Poster
Tsorf_Dev
0
Newbie Poster
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
Tsorf_Dev
0
Newbie Poster
jon.kiparsky
commented:
Don't post broken code!
+0
jon.kiparsky
326
Posting Virtuoso
jon.kiparsky
326
Posting Virtuoso
Tsorf_Dev
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.