- public class Test1 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String s = "ajdsahdhfha";
- char[] arr = s.toCharArray();
- for (int i = 0; i < arr.length; i++) {
- System.out.print(arr[i]);
- }
- System.out.println();
- // 2.统计一个字符串中大写字母,数字的数量;
- String s1 = "KJGGLhkjkgKJGKJgGGl3663816238";
- int lagenum = 0;
- int num = 0;
- char[] arr1 = s1.toCharArray();
- for (int i = 0; i < arr1.length; i++) {
- if (arr1[i] >= 'A' && arr1[i] <= 'Z') {
- lagenum++;
- }
- if (arr1[i] >= '0' && arr1[i] <= '9') {
- num++;
- }
- }
- System.out.println("lagenum=" + lagenum + "num=" + num);
- }
- }
复制代码
|
|