Reda
Reda

Reputation: 157

How to create an instance of IntList?

I try to use a package of collections called fastutil, but I'm not able to create an instance of IntList.

I've tried using the default constructor call, but it did not work.

IntList foo = new IntList();

How can I create a new instance of IntList ?

Upvotes: 0

Views: 1349

Answers (1)

Jean-François Savard
Jean-François Savard

Reputation: 21004

IntList is an interface. So you can't directly initialize it, you need to initialize an Object that implements the interface in order to have an instance of IntList.

Here an example :

IntList foo = new IntArrayList();

You might want to see IntArrayList constructors for possible instantiation.

Note that all known classes that implement IntList are

  • AbstractIntList
  • AbstractIntList.IntSubList
  • IntArrayList
  • IntLists.EmptyList
  • IntLists.Singleton
  • IntLists.SynchronizedList
  • IntLists.UnmodifiableList

Upvotes: 3

Related Questions