I am currently trying to convert a string inputted by the user, into
all lower case characters. I have discovered that my method will work
until it comes across a space in the string, at which point it stops
all together.
How do I print a string which contains spaces?
How do I convert the string all to lower case if it contains spaces?
Any help I can get will be much appreciated.
Roderick Olliver - 14 May 2004 23:19 GMT
> I am currently trying to convert a string inputted by the user, into
> all lower case characters. I have discovered that my method will work
[quoted text clipped - 6 lines]
>
> Any help I can get will be much appreciated.
System.out.println( "SpongeBob Square PANTS ".toLowerCase() );
spongebob square pants
$
Is that what you mean?
Roedy Green - 15 May 2004 01:50 GMT
>I am currently trying to convert a string inputted by the user, into
>all lower case characters. I have discovered that my method will work
>until it comes across a space in the string, at which point it stops
>all together.
None of the methods I know of fail on spaces. Show us your code.

Signature
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Mikael Laine - 16 May 2004 15:58 GMT
If you are taking the string as command-line arguments it considers the
next word after the space another argument. So if you have something like:
public static void main(String args[]){
System.out.println(args[0].toLowerCase());
}
you need to change it to
public static void main(String args[]){
String str="";
for(int i=0;i<args.length;i++){
str+=args[i]+" ";
}
System.out.println(str.toLowerCase());
}
But if you are not doing this, then I don't know what's wrong :)
Send in the code Sarah...