I have to arrays with integers:
int[] a={1,2,3,4,5};
int[] b={6,7};
I would like to generate an array, which contains pairs from the a and b arrays, in a random order, without duplicates. For example I would like to get the following result:
c={(1,6),(2,7),(4,6),...}
Thanks!
Here is some code which creates 10 random pairs from your input
a[]
andb[]
arrays, and stores them into anHashSet
which you can use later as you see fit. TheHashSet
will automatically remove duplicate pairs.