Hi to all,
-------------
Here there is array of ten position and array contain ten integers .
I want to put the array of ten integers randomly on the array of ten position ...
Here is my code :
----------------------
import java.util.Random;
public class TestArray {
public static void main(String[] arg) {
int[] array;
int[] arr = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int size = 10;
array = new int[size];
Random random = new Random();
for (int i = 0; i < array.length; ++i) {
System.out.print(array[i] + " ");
}
System.out.println();
for (int i = 0; i < array.length; ++i) {
array[i] = random.nextInt(arr[i]);
System.out.println(array[i] + " ");
}
}
}
the first for loop print :
0 0 0 0 0 0 0 0 0 0
In the second for loop i want to put the array of ten integer randomly in the first array
but it give me this exception:
java.lang.IllegalArgumentException:
please tell me why this and how can i adjust this ?
thanks in advance