Hi dear Friends, I want to change an array of string to a string in java?can anyone help me with?I do need your help. thanks!!!
shadowfiend. can you help me with?
Ahm.. I'm no Java-guy, but how about something like: String[] foo = {"some", "array", "of", "strings"}; String bar = ""; for(int i=0; i<foo.length; i++) bar += foo[i]; ??? Where foo[] is the array of strings you got and bar is the resulting string.. Hope that's what u wanted..?
thanks!it is so nice!
you're very welcome ;)
MuH4hA's answer is correct; with a "foreach" loop (since Java 1.5) you can even save the i: final String[] foo = {"some", "array", "of", "strings"}; String bar = ""; for (String string : foo){ bar += string; } Note that if this is performance-critical code, you should be using a StringBuffer instead of concatenating strings.
thank you both!you are all so kind!
np
Join our real-time social learning platform and learn together with your friends!