i wanted to get the uppercase characters in the string and also there count
package TEST;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class case_test {
public static void main(String agrs[]) {
String str1 = "", regx;
regx = "[A-Z]+";
Scanner sc = new Scanner(System.in);
Pattern pattern = Pattern.compile(regx);
Matcher matcher = pattern.matcher(str1);
int count = 0;
System.out.println("ENTER A SENTENCE");
str1 = sc.nextLine();
while (matcher.find())
System.out.println(str1.substring(matcher.start(), matcher.end())
+ "*");
count++;
}
}
I wanted to get the uppercase characters in the string and also their amount.