Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Primitive array of ArrayLists

807600Nov 23 2007 — edited Nov 23 2007
Can I just create a primitive array of ArrayList?

I tried the ArrayList of ArrayLists thing - I think it's ugly and counter intuitive.

I can't seem to come up with the correct syntax.
ArrayList<Coordinate>[] moves = new ArrayList<Coordinate>[5]; //"generic array creation"
import java.util.ArrayList;
public class Sandbox
{   
    ArrayList<Coordinate>[] c;
    public Sandbox()
    {
        c = new ArrayList[5];
        c[0] = new ArrayList<Coordinate>();
        c[0].get(0) = new Coordinate(1, 3); //<----unexpected type
    }
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 21 2007
Added on Nov 23 2007
6 comments
274 views