package com0000; //不存在 相同数 public class Demo { public static void main(String[] args) { int[] a = new int[6]; for (int i = 0; i < a.length; i++) { int b = (int) (Math.random() * 30) + 1; a[i] = b; for (int j = 0; j < i; j++) { if (a[i] == a[j]) { i--; break; } } } for (int j = 0; j < a.length; j++) { System.out.print(a[j] + " "); } } }