bano6010
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.
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)
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));
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try using Character.isLowerCase(a.ch arAt(i)) in your if statement.
ASKER
That was it, thanks a bunch!