Your myArrayOne
method calls itself. That's the problem with infinite recursion.
public static int myArrayOne() {
// that's the problem
return myArrayOne();
}
That is probably what are you trying to accomplish:
// void --> List<Integer>
// static
public List<Integer> myArrayOne() {
ArrayList<Integer> packOfCards = new ArrayList<Integer>();
Random rand = new Random();
for (int j = 0; j<5; j++)
{
pick = rand.nextInt(10);
packOfCards.add(pick);
}
// myArrayOne(); --> packOfCards
return packOfCards;
}
public static void main(String[] args) {
myattributes attributes = new myattributes();
List<Integer> values = attributes.myArrayOne();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.