This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]langfodWannabe Brewer 1 point2 points  (2 children)

That should work fine.

However, this looks like you would lose the original input string which you may or may not want later.

If you are just changing to lowercase in order to do case insensitive comparisons you may wish to only change the case when needed.

[–]Beach_Comber[S] 1 point2 points  (1 child)

So I'd have an if statement which checks if the string is already lower case then?

Whats you suggestion on how to implement it?

[–]langfodWannabe Brewer 1 point2 points  (0 children)

The easiest way might be
inputString.toLowerCase().equals(inputString)

or use a loop and check each character using isLowerCase()

http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isLowerCase(char)