java - Finding uppercase characters in a user's string and counting them -
i wanted uppercase characters in string , 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 sentence"); str1 = sc.nextline(); while (matcher.find()) system.out.println(str1.substring(matcher.start(), matcher.end()) + "*"); count++; } }
i wanted uppercase characters in string , amount.
you can use string intersection (intersection of 2 strings in java) using originalstring & originalstring.touppercase().
Comments
Post a Comment