Tag:uppercase number ++ str string stat api abc practice
/*public class test1{public static void Main (String[]args) {String s = "abcdeEFHDKEI38475"; Char a[] = S.tochararray (); int lower = 0,upper = 0,other = 0; for (int i=0; i<a.length; i++) {if (a[i]<= ' z ' && a[i]>= ' a ') lower++; else if (a[i]<= ' Z ' && a[i]>= ' a ') upper++; else other++; } System.out.println (lower); SYSTEM.OUT.PRINTLN (upper); System.out.println (other); }}*//*public class test1{public static void Main (String[]args) {String s = "abcdeEFHDKEI38475"; int lower = 0,upper = 0,other = 0; for (int i=0; i<s.length; i++) {char c = s.charat (i); if (c<= ' z ' && c>= ' a ') lower++; else if (c <= ' Z ' && C >= ' A ') upper++; else other++; } SyStem.out.println (lower); SYSTEM.OUT.PRINTLN (upper); System.out.println (other); }}*//*public class test1{public static void Main (String[]args) {String SL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String SU = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String s = "abcdeEFHDKEI38475"; int lower = 0,upper = 0,other = 0; for (int i=0; i< s.length (); i++) {char c = s.charat (i); if (Sl.indexof (c)! =-1) lower++; else if (Su.indexof (c)! =-1) upper++; else other++; } System.out.println (lower); SYSTEM.OUT.PRINTLN (upper); System.out.println (other); }}*/public class test1{public static void Main (String[]args) {String SL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String SU = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String s = "abcdeEFHDKEI38475"; int lower = 0,upper = 0,other = 0; for (int i=0; i< s.length (); i++) {char c = s.charat (i); if (Character.islowercase (c)) lower++; else if (Character.isuppercase (c)) upper++; else other++; } System.out.println (lower); SYSTEM.OUT.PRINTLN (upper); System.out.println (other); }}
Key idea: Extract each character in the string and compare it. See the Java API documentation for details. Https://docs.oracle.com/javase/8/docs/api/index.html
Java Exercise: Specify the number of uppercase, lowercase, and other characters in the specified string.