Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两条消息“Job 1”和“Job 2”。我想将这些消息放入循环中,并且每次执行时都会随机显示输出:比如
Job1 job2 job2 job1 and so on..
使用随机类
把它们放在一个列表中,然后说:
for(i = 0; i < howeverManyTimesYouWantToLoop; i++) { System.out.println(jobList.get(new Random().nextInt(jobList.size())); }