Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uppercase character method? 2

Status
Not open for further replies.

jisoo22

Programmer
Apr 30, 2001
277
US
Does anyone happen to know if there is a method that checks if a character is uppercase? I searched through the 1.4.1 API and only found "toUpperCase()" for strings.

Thanks,
Jisoo22
 
static boolean java.lang.Character.isUpperCase(char)

-pete
 
Quick question,

If I had a for loop like the following:

Code:
String source = s.toUpperCase();
for (int i = 0; i < s.length(); ++i) {
    char c = source.charAt(i);

    if (??.isUpperCase() == true) {
       String temp = temp + alphabet[i];
    }
}

Could I substitute &quot;c&quot; for the &quot;??&quot;? I seem to get an error message about a char not being able to be dereferenced.

Thanks,
Jisoo22
 
Hi jisoo22,

The method you want is in Character not in the basic java type char. It is a static method so you don't need to make a new instance of it to use...just put :

..
if (Character.isUpperCase(c)) {
..

Should work.

Kev
[afro2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top