Technically, you can store anyhing inside ArrayList<String>.
However, this requires unchecked calls and is strongly discouraged. The compiler will give you a warning.This prints:
[Hello, 1, java.lang.Object@12a3a380]
You can not store primitive values in an ArrayList. In the example above (line 6) there is the autoboxing happening and what really is stored is an instance of Integer.
I would say the correct way to declare and instantiate a List is like this:-
List<Foo> myList = new ArrayList<Foo>();
That is called programming to the interface: you can use every method in the List interface and can change the implementation to LinkedList or similar very simply. In Java7 you have type inference
List<Foo> myList = new ArrayList<>();
You can find more about the <> in the Java™ Tutorials.
A wop bop a lu bob a womp bam boom. Tutti frutti ad: