///小写字母public class test6 { public static void main(String[] args) { System.out.println(ram(6)); } public static String ram(int n){ String code="";//空字符串 Random r = new Random(); for (int i = 0; i <n ; i++) { int type = r.nextInt(3); switch (type){ case 0://大写字母 char ch= (char) (r.nextInt(26)+65); code += ch; break; case 1://小写字母 char ch1 = (char) (r.nextInt(26)+96); code+=ch1; break; case 2://数字 int num = r.nextInt(10); code+=num; break; } } return code; } }
//黑马程序员笔记