How do I get a list of five random numbers to be printed without duplicates in Java?
问题 I'm trying to get five random numbers printed that never repeat, based on a certain range provided by the user. Posted below is the code I have so far. Firstly, I don't know how to list the numbers found in the ArrayList, or even if I should use ArrayList over just an Array. Any thoughts? package h1p2; import java.util.ArrayList; public class test{ public void method (int min, int max){ //Declare and initialize arrays and index variables ArrayList<Integer> rangeOne = new ArrayList<Integer>();