因此,我正在开发一个OOP程序,该程序旨在通过使用随机数生成器创建50个唯一数字,确保不重复数字.我有随机部分,我正在使用一个额外的方法交换数字,但我不知道只交换数字,如果他们已经使用,我希望这是可以理解的.
import java.util.Random;
public class Project_1
{
public static void main(String[] args)
{
Random rand = new Random();
int a[][] = new int[11][6];
for (int i = 1; i <= 10; i++) //row of values which fill in Student number
{
System.out.print("Student " + i + ":");
System.out.print("\t");
for (int j = 1; j <= 5; j++) //j is limited up to 5 columns
{
a[i][j] = 1 + rand.nextInt(50);
CheckNumbers(a[i][j]); //input of the checkNumbers method
System.out.print(a[i][j] + "\t"); // …Run Code Online (Sandbox Code Playgroud)