The Character class is a subclass of the Object class, which encapsulates the value of the original type char in an object. Objects of class Character contain a single field of type char.
We can print out all the uppercase letters by iterating over the characters of the string in a loop and using the isUpperCase() method to check if a single character is uppercase. The isUpperCase() method is a static method of the Character class.
public static boolean isUpperCase(char ch)
public class PrintUpperCaseLetterStringTest { public static void main(String[] args) { String str = "Welcome To Tutorials Point India"; for(int i = 0; i < str.length(); i++) { if(Character.<strong>isUpperCase</strong>(str.<strong>charAt</strong>(i))) { System.out.println(str.<strong>charAt</strong>(i)); } } } }
W T T P I
The above is the detailed content of How can we print all uppercase letters in a given string in Java?. For more information, please follow other related articles on the PHP Chinese website!