So i have two methods to create a randomized array and arraylist with 100 random integers. For some reason only the arraylist works though. Not sure what is wrong. Can someone take a look at it? I really don't know why it doesn't work. Is there a better way to randomize an array?
public static int[] gen1()
{
int[] no = new int[100];
for(int i=0;i<no.length;i++)
{
no[i] =(int)(Math.random());
}
return no;
}
public static ArrayList<Integer> gen2()
{
ArrayList<Integer> oh = new ArrayList<Integer>();
Random random = new Random();
for (int i = 0; i < 100; i++)
{
oh.add(random.nextInt());
}
return oh;
}
public static void main(String[] args)
{
System.out.println("Original Array:");
System.out.println(gen1());
System.out.println("Original List:");
System.out.println(gen2());
}