/**
 * create a new Animal object of generic type A.
 * invoke with Dog d = animalFactory( Dog.class );
 * @param class of Animal you want to create. e.g. Dog.class
 * @return newly constructed Animal object of the desired class
 */
public static <A extends Animal> A animalFactory( Class<A> type )
   {
   return(A) type.newInstance();

   // array of animals would be
   // return (A[])Array.newInstance( type, size );
   }