Link to home
Start Free TrialLog in
Avatar of bano6010
bano6010Flag for United States of America

asked on

Combine toUpperCase() and string.charAt()

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

ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try using Character.isLowerCase(a.charAt(i)) in your if statement.
Avatar of bano6010

ASKER

That was it, thanks a bunch!