Skip to main content

Command Palette

Search for a command to run...

Find upper and lower case from string.

Updated
1 min read
Find upper and lower case from string.
G

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.

I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.

Write a Java program to find the upper and lower case from string and print count.

import java.util.*;

import static java.lang.System.in;

public class demo {
    public static void main(String[] args) {
        String str = "Gulshan Kumar";
        int len = str.length();
        String capsString = "";
        String smallString = "";
        int small = 0;
        int caps = 0;

        for (int i=0; i<len; i++){
//            The range A-Z is mapped to [65-90]
//            nd [a-z] is mapped to [97-122]
            if (str.codePointAt(i)>64 && str.codePointAt(i)<91){
                capsString += str.charAt(i)+" ";
                caps++;
            } else if (str.codePointAt(i)>96 && str.codePointAt(i)<123) {
                smallString += str.charAt(i)+" ";
                small++;

            }

        }
        System.out.println("Small letters in String are : "+smallString +
                "\nand count of the letters is : "+ small);

        System.out.println("***********************************");

        System.out.println("Capital letters in String are : "+capsString +
                "\nand count of the letters is : "+ caps);


    }
} // main block

/*
output 
Small letters in String are : u l s h a n u m a r 
and count of the letters is : 10
***********************************
Capital letters in String are : G K 
and count of the letters is : 2
*/

More from this blog

S

Software and Performance Testing Insights

462 posts

Results-Driven Agile QA Specialist | Expert in Mobile & Web Testing | Proficient in Test Planning, Execution, and Root Cause Analysis.