i dont really know much yet because its out first time dealing with arrayspublic class Arrays { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x, y =0; int [] list; list = new int [10]; int [] list2; list2 = new int [10]; x =(int)(99*Math.random()+1); y=(int)(99*Math.random()+1); int array = 9; int [] list3; list3 = new int [10]; int [] list4; list4 = new int [10]; int i; System.out.print("List 1 : "); for (i = 0 ; i<=list.length ; i++) list [i] = x =(int)(99*Math.random()+1); System.out.print(list[i]);
i want to input a random value between 1-99 in list[0]-list[9] so i used a for loop is this possible?
i previously have this other code which is really long so i wondered if i could use a for loop please help...
list[0] = x; x =(int)(99*Math.random()+1); list[1] = x; x =(int)(99*Math.random()+1); list[2] = x; x =(int)(99*Math.random()+1); list[3] = x; x =(int)(99*Math.random()+1); list [4] = x; x =(int)(99*Math.random()+1); list [5] = x; x =(int)(99*Math.random()+1); list [6] = x; x =(int)(99*Math.random()+1); list [7] = x; x =(int)(99*Math.random()+1); list [8] = x; x =(int)(99*Math.random()+1); list [9] = x; x =(int)(99*Math.random()+1); list2[0] = x; x =(int)(99*Math.random()+1); list2[1] = x; x =(int)(99*Math.random()+1); list2[2] = x; x =(int)(99*Math.random()+1); list2[3] = x; x =(int)(99*Math.random()+1); list2[4] = x; x =(int)(99*Math.random()+1); list2[5] = x; x =(int)(99*Math.random()+1); list2[6] = x; x =(int)(99*Math.random()+1); list2[7] = x; x =(int)(99*Math.random()+1); list2[8] = x; x =(int)(99*Math.random()+1); list2[9] = x; x =(int)(99*Math.random()+1);