我想从一个数组中随机选择一个元素进行打印,然后将其从数组中删除,以避免重复打印相同的数字。由于我是Java的新手,所以想知道是否有人能指出我的错误所在。
public static void main(String[] args) {
int[] colm = { 1, 2, 3, 4, 5, 67, 87 };
Random rand = new Random();
for (int i = 0; i < 5; i++)
System.out.println(" " + colm[rand.nextInt(colm.length)]);
}
thanks