View Single Post
Old 03-23-2005, 06:13 AM   PM User | #9
hinokata
New Coder

 
Join Date: Mar 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
hinokata is an unknown quantity at this point
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.
hinokata is offline   Reply With Quote