|
Although using java.util.* is perfectly acceptable, it is better to only import exactly what you need, in this case: import java.util.ArrayList. This way you only pull in what you need and not the everything in Collections.
In Java 1.5+, you can also specify the type of data you will be storing in there (autoboxing) like so: ArrrayList foo = new ArrayList<String>(1024); This makes it so that you can only place Strings into the ArrayList, but you also don't have to cast the object to a String when you pull it out. You'll find that by doing that, you will save yourself some typing down the road.
|