Joined September 2013
·

Christian Haas

Vienna, Austria, Europe, Earth, Sol
·
·

Posted to Create multiple objects in Java. over 1 year ago

Interesting.
Another issue though: newInstance() requires some exceptions to be handled (InstantiationException, IllegalAccessException).

Apart from that, with the new streams in Java 8 this can be achieved in one go:
List<Human> result = Stream.generate(Woman::new).limit(10).collect(Collectors.toList());

Achievements
63 Karma
1,240 Total ProTip Views