Combine toUpperCase() and string.charAt()

bano6010
bano6010 used Ask the Experts™
on
Hello Experts,

I am trying to combine string.,charAt() and toUpperCase(). What I want to do is take a string; a, and have each letter in a loop made upper case.  This way the program will only print the non-lower case characters.

The statement "a.toUpperCase(a.chatAt(i));" causes my compiler to fail. What statement will allow me to change each char in  string to uppercase like my example bellow.

My goal is to get my program to reprint the string without printing the capital letters.

Thanks in advance.
for (int i = 1; i < a.length(); i++) {
   if (a.charAt(i) != a.toUpperCase(a.chatAt(i))) {
      System.out.print (charAt(i));
   }
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Java Developer
Top Expert 2010
Commented:
  if (a.charAt(i) != a.toUpperCase().charAt(i))) {
CPColinSenior Java Architect

Commented:
Try using Character.isLowerCase(a.charAt(i)) in your if statement.

Author

Commented:
That was it, thanks a bunch!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial