赞
踩
实现方法不唯一,此方法仅作初学者(自己)参考。。。。。
所用类API介绍:
所用方法介绍:
实现代码:
package com.string; import java.util.Scanner; import java.util.SplittableRandom; public class Print_Stirng { public static void main(String[] args) { System.out.println("请输入字符串:"); Scanner scan = new Scanner(System.in); String str = scan.nextLine(); char[] s = str.toCharArray(); System.out.print("小写字母: "); for (char s1:s) { if(Character.isLowerCase(s1)) System.out.print(s1+" "); } System.out.println(); System.out.print("大写字母:"); for (char s2:s) { if (Character.isUpperCase(s2)) System.out.print(s2+" "); } System.out.println(); System.out.print("数字:"); for (char s3:s) { if (Character.isDigit(s3)) System.out.print(s3+" "); } } }
实现结果:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。