Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most efficient Java primitive collections library [closed]

What is the best Java primitive collections library? (most memory and time efficient)

I've found Trove and FastUtil to be the most used ones, but haven't found much comparison between them (or between others)

Is there any comparison available?

like image 532
Sarmun Avatar asked Jul 22 '10 09:07

Sarmun


People also ask

Which is best collection in java?

The best general purpose or 'primary' implementations are likely ArrayList , LinkedHashMap , and LinkedHashSet . Their overall performance is better, and you should use them unless you need a special feature provided by another implementation. That special feature is usually ordering or sorting.

Can Java collections hold primitives?

Collections are the framework used to store and manipulate a group of objects. Java Collection means a single unit of objects. Since the above two statements are true, generic Java collections can not store primitive types directly.

Why Java collections Cannot directly store primitives types?

It's a combination of two facts: Java primitive types are not reference types (e.g. an int is not an Object ) Java does generics using type-erasure of reference types (e.g. a List<?> is really a List<Object> at run-time)

Can we store primitive data types in collection?

Since primitive types cannot be used in Collections or Generics, each time i is added to numbers a new Integer object is created.


1 Answers

This comparision between Java standard collections, Trove and Colt might be helpful.

like image 165
Guy Sensei Avatar answered Sep 17 '22 19:09

Guy Sensei