Searching multiple arrays

I new to java and I would appreciate any help with a problem that I have. I have three arrays which should hold different values. Once initialized they have 0 as the inital value. My problem is how to populate these arrays with different and unique values. In order to copy a value to any of the arrays, I have to check for the prescence of that value in each array. If it is not in any of the arrays then I can copy it to the array. I would appreciate any help with this. Thanks.

[487 byte] By [xataxa] at [2007-10-3 7:44:35]
# 1

You could write a method that takes an array and an int to search for. The method will return true or false. Then call that method 3 times passing in a different array each time.

if(! isNumberInArray(arr1, number) && ! isNumberInArray(arr2, number) && ! isNumberInArray(arr3, number)) {

insert number;

}

floundera at 2007-7-15 2:45:51 > top of Java-index,Java Essentials,New To Java...
# 2

int arr1[] = new int[5];

int arr2[] = new int[5];

int arr3[] = new int[5];

Vector v = new Vector();

for (int i=1; i<=100; i++) v.add(Integer.toString(i));

Collections.shuffle(v);

for(int i=0; i<5; i++) arr1[i] = Integer.parseInt(v.get(i).toString());

for(int i=0; i<5; i++) arr2[i] = Integer.parseInt(v.get(i+5).toString());

for(int i=0; i<5; i++) arr3[i] = Integer.parseInt(v.get(i+10).toString());

Cheers

astelaveestaa at 2007-7-15 2:45:51 > top of Java-index,Java Essentials,New To Java...