how t ocheck if given String is in uppercase or lowercase?

how t ocheck if given String is in uppercase or lowercase?

[65 byte] By [AmitChalwade123456a] at [2007-11-27 11:47:37]
# 1

You could compare the result of string.toUpperCase() to the string itself. If it was uppercase already, the 2 strings would be the same. I'll leave it up to you to work out how to check if it's lower case :-)

georgemca at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 2

b yus in gprop erinterp unct ionm aybe ?

just compare it to the same string converted to uppercase or lowecase...

jwentinga at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 3

Or just iterate over the String's chars and ask Character.isUpperCase().

CeciNEstPasUnProgrammeura at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 4

WTF!? Refreshed and it still showed the old version of this thread?

CeciNEstPasUnProgrammeura at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 5

b yus in gprop erinterp unct ionm aybe ?

just compare it to the same string converted to uppercase or lowecase...

jwentinga at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 6

ok that solved my problem thanks a lot frens

AmitChalwade123456a at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 7

I know that you already have solved the problem, but another option would be to use regexp.

Kaj

kajbja at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 8

String str = str. replaceAll("[A-Z]+" , "");

i THINK THIS IS fine

AmitChalwade123456a at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 9

> String str = str. replaceAll("[A-Z]+" , "");

> i THINK THIS IS fine

I would have used String.matches(String regex) instead :)

kajbja at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...
# 10

that is correct

AmitChalwade123456a at 2007-7-29 18:14:20 > top of Java-index,Java Essentials,Java Programming...