- 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.
Program #1: Java example program to find all capital letters / Uppercase letters in a String
- package findUppercaseletters.String;
- public class FinfUppercaseLetters {
- /**
- *
- */
- 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
No comments:
Post a Comment