Generics CreateList


Creating an ArrayList with different types of Objects can be seen as Generic. In an ArrayList you can put any Object you want. Strings, Arrays and whatever you can think off:

List<?> list = new ArrayList<?>();

list.add(new Integer(123));
list.add(new String ("Hello"));
list.add(new String[] {"One","Two","Three");
list.add new java.util.Date();


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.