// Converting array to List to Collection to array

// Convert an array to a List:
final String[] animals = { "bear", "cougar", "wolverine"};
final List<String> list = Arrays.asList( animals ) );

// A List can then be fed to the constructor or addAll method
// of many Collections:
final Collection<String> h = new HashSet<String>( list );

// Convert a Collection back to an array, no (String[]) cast needed.
final String[] predators = h.toArray( new String[ h.size() ] );

// The above toArray technique works only with
// Object[], not int[], short[], long[] etc.
// To extract a primitive array you need code like this:
final List<Short> reps = new ArrayList( 10 );
...
final short[] reparray = new short[ reps.size() ];
int i = 0;
// autounboxing Short -> short
for ( short rep: reps )
   {
   reparray[ i++ ] = rep;
   }