0% found this document useful (0 votes)
39 views1 page

String Q5

The document contains Java code that counts the number of integers, uppercase characters, and lowercase characters in the string "Hello Java 8". The code converts the string to a character array, initializes counters, and uses Character methods to iterate through the array, incrementing the appropriate counter for each character type. It outputs that there is 1 integer, 2 uppercase characters, and 7 lowercase characters in the given string.

Uploaded by

Nithin V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views1 page

String Q5

The document contains Java code that counts the number of integers, uppercase characters, and lowercase characters in the string "Hello Java 8". The code converts the string to a character array, initializes counters, and uses Character methods to iterate through the array, incrementing the appropriate counter for each character type. It outputs that there is 1 integer, 2 uppercase characters, and 7 lowercase characters in the given string.

Uploaded by

Nithin V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

5.

WJP to find the number of Integers , uppercase, lowecase characters in a given


String "Hello Java 8" Integer - 1 uppercase - 2 lowercase - 7

package Trainingpractice;

public class charactercount {


public static void main(String[] args) {
String s1="Hello Java 8";
char[]charArray=s1.toCharArray();
int upper=0,lower=0,number=0;
for(char c :charArray){
if(Character.isUpperCase(c)) {
upper++;
} else if (Character.isLowerCase(c)) {
lower++;
}
else if (Character.isDigit(c)) {
number++;
}
}
System.out.println("Integer - " + number);
System.out.println("Uppercase - " + upper);
System.out.println("Lowercase - " + lower);
}
}

Op-
Integer - 1
Uppercase - 2
Lowercase - 7

You might also like