java语言产生多个随机字符串代码正确版

50 阅读1分钟

正确例题 import java.util.Random; public class Test { public static void main(String[] args) { String [] arr=new String[]{"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"}; Random random = new Random(); for(int i=0;i<10;i++){ for(int j=0;j<10;j++){ int s = random.nextInt(12); System.out.println(arr[s]); } } } }