ArrayList t = new ArrayList();
t.add(1);
t.add(10.5f);
t.add("qlq ch");
//get array
Object[] obj = t.toArray();
ArrayListt = new ArrayList ();
t.add(34);
t.add(10);
t.add(54);
Object[] obj = t.toArray();
int[] obj_int = new int[obj.length];
for(int i=0; i < obj_int.length; i++)
//Convert objects to int
obj_int[i]=(int) obj[i];
ArrayListReferences:tm = new ArrayList ();
//populate the list
for(int i=0; i < list.size(); i++){
ArrayList al = new ArrayList();
for(int i1=0; i1 < list.size(); i1++)
//generate random numbers
al.add(Math.random());
tm.add(al);
}
Object[][] mt = new Object[tm.size()][tm.get(0).size()];
for(int i = 0 ; i < tm.size(); i++)
//copy the values into each row of the array
mt[i] = tm.get(i).toArray();
//display
for(int i=0; i < mt[0].length; i++){
for(int j=0; j < mt[0].length; j++)
System.out.print(mt[i][j]+" ");
System.out.println(" ");
}
Please disable your ad blocker and refresh the window to use this website.