日期:2014-05-20 浏览次数:20936 次
String chars = "abcdefghijklmnopqrstuvwxyz"; System.out.println(chars.charAt((int)(Math.random() * 26)));
------解决方案--------------------
ArrayList list = new ArrayList(); for (char c = 'a'; c <= 'z'; c++) { list.add(c); } String str = ""; for (int i = 0; i < 5; i++) { int num = (int) (Math.random() * 26); str = str + list.get(num); } System.out.println(str);