Menu Bar

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, 18 January 2017

Write a Java Program to Count UpperCase Character in Given String ?


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
public class CountUpperCaseCharacter {
 
 public static void getCount(String s1){
  int count = 0;
  for(char ch : s1.toCharArray()){
   if(Character.isUpperCase(ch)){
    count++;
   }
  }
  
  System.out.println("TOTAL UPPERCASE CHARACTER IN STRING : "+s1+" ,is : "+count);
 }
 public static void main(String[] args) {
  CountUpperCaseCharacter.getCount("Pushkar");
  CountUpperCaseCharacter.getCount("AbcDffffGH");
 }
}

Output:

TOTAL UPPERCASE CHARACTER IN STRING : Pushkar ,is : 1
TOTAL UPPERCASE CHARACTER IN STRING : AbcDffffGH ,is : 4


      
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.



Share this Blog with yours Friends !!

No comments:

Post a Comment