- How can we count upper case letter in String java ?
- How to find uppercase letters in String java?
- How to find capital letters in string in java?
- How u discover the capital letter given sentence?
- Yes We can find uppercase or capital letters in a String using isUpperCase() method of Character class in java
- In order to find number of uppercase letters in a string of all capital letters in a string we need to iterate all characters of a string in a loop and check individual characters are uppercase letters or not using Character class provided isUpperCase() method.
- To find the uppercase letters in a string in Java, you can use the isUpperCase() method of the Character class.
Program #1: Java example program to find all capital letters / Uppercase letters in a String
- package findUppercaseletters.String;
- public class FinfUppercaseLetters {
- /**
- * @website: www.instanceofjava.com
- */
- public static void main(String[] args) {
- String str= "How to Print Uppercase Letters in Java";
- for (int i = 0; i < str.length(); i++) {
- if(Character.isUpperCase(str.charAt(i))){
- System.out.println(str.charAt(i));
- }
- }
- }
- }
Output:
- H
- P
- U
- L
- J
- Above code will print all the uppercase letters in the string.
- Alternatively, you can also use the toUpperCase() method of the Character class to convert all the characters in the string to uppercase and then use the equals() method to compare them to the original character.
No comments