Forgot your
password?
HOME
FAQS
FORUMS
DOWNLOADS
ARTICLES
PEERSCOPE
LEARN
Search
View:
What's New
Index by Topic
Contributors
Topic List
Printable View
Unanswered Questions
Suggested Path
Collections FAQ Home Page
FAQ Manager is guru
Brandon Rohlfs
.
The Collections Framework offers support for Abstract Data Types (ADTs) beyond Vector and Hashtable starting with the Java 2 platform, version 1.2.
What's New
Why should all Comparators be Serializable?
Java:API:Collections
John Zukowski
PREMIUM
, Sep 28, 2007
If you pass a Comparator that doesn't implement Serializable into a collection like a TreeMap, that collection will automatically be non-serializable....
What purpose does the newSetFromMap() method offer if I can just create something like a HashSet instead of a HashMap?
Java:API:Collections
John Zukowski
PREMIUM
, Sep 28, 2007
The Set returned by newSetFromMap() functions with the same ordering and concurrency characteristics of the map it is based off of. Some Map implementations...
What is a Deque?
Java:API:Collections
John Zukowski
PREMIUM
, Sep 28, 2007
A Deque is a double ended queue, allowing inserting and removing from both ends.
What does Class<String> mean?
Java:API:Collections
,
Java:Language:Declarations
John Zukowski
PREMIUM
, Oct 31, 2006
Class<String> is the generics way of writing String.class. It allows you to improve type safety.
What does Class<String> mean?
Java:API:Collections
,
Java:Language:Declarations
John Zukowski
PREMIUM
, Oct 31, 2006
Class<String> is the generics way of writing String.class. It allows you to improve type safety.
What is the natural ordering of a Boolean? Does FALSE come first or second?
Java:API:Collections
,
Java:Language:Classes
John Zukowski
PREMIUM
, Oct 31, 2006
Boolean.FALSE < Boolean.TRUE
How do I create a multimap in Java?
Java:API:Collections
John Zukowski
PREMIUM
, Oct 31, 2006
Typically a Map maps a key to a single value. To have a multimap, the values of a Map should be a List instead. Thus there can be multiple values in the...
What is a multimap?
Java:API:Collections
John Zukowski
PREMIUM
, Oct 31, 2006
A multimap is a map where a single key can map to multiple values. (And a value can be associated with multiple keys.)
What is a multimap?
Java:API:Collections
John Zukowski
PREMIUM
, Oct 31, 2006
A multimap is a map where a single key can map to multiple values.
How can I detect if a duplicate is added to a Set?
Java:API:Collections
John Zukowski
PREMIUM
, Oct 31, 2006
The add() method returns a boolean. If the set did not previously contain the element, true is returned. If the set previoulsy did contain the element,...
Is it better to use a for-each loop or an Iterator with a collection?
Java:API:Collections
John Zukowski
PREMIUM
, Oct 31, 2006
It depends on what you need to do. The remove() method of an Iterator is the safe way to remove elements from an underlying collection. You can't safely...
Why do I keep getting an UnsupportedOperationException thrown when I try some collection operations?
Java:API:Collections
John Zukowski
PREMIUM
, Oct 31, 2006
Several methods of the collection interfaces are considered optional. If an unsupported operation is called, that is when you'll see the UnsupportedOp...
What implementations of the Deque interface does Java offer?
Java:API:Collections
John Zukowski
PREMIUM
, Sep 30, 2006
ArrayDeque offers an array backed deque. LinkedList offers a linked list version. LinkedBlockingDeque offers an optionally bounded blocking version.
How do you pronounce Deque?
Java:API:Collections
John Zukowski
PREMIUM
, Sep 30, 2006
Deque is pronounced like deck, not de-queue.
What is the purpose of the CopyOnWriteArrayList and CopyOnWriteArraySet collections?
Java:API:Collections
,
Programming:Concepts:Threads
John Zukowski
PREMIUM
, Jun 30, 2006
Synchronized operations are costly and if you aren't modifying a collection much, it is best not to synchronize all collection accesses. The CopyOnWriteXXX...
How do I make a copy of an array?
Java:API:Collections
John Zukowski
PREMIUM
, Jan 22, 2006
The arraycopy method of System allows you to do this but... starting in Java 6, there is a new copyOf() method added to the Arrays class that is slightly...
How can I insert an element into a List?
Java:API:Collections
Brandon Rohlfs
, Sep 23, 2005
In order to insert an element into a List add(int index, E element) must be used since the List interface does not provide an insert method. If the index...
What is the difference between a Stack and a Queue?
Java:API:Collections
Brandon Rohlfs
, Sep 20, 2005
First things first. Where can Stacks and Queue's be found? Java provides a Stack class, which can be found within the java.util namespace. Within...
How can I create an immutable List consisting of n Copies of an Object?
Java:API:Collections
Brandon Rohlfs
, Sep 14, 2005
nCopies(int n, T o) can be used to create an immutable List which contains a specific number of copies of an Object. Care must be taken when trying to...
How can I find the maximum element contained within a Collection?
Java:API:Collections
Brandon Rohlfs
, Sep 8, 2005
Finding the maximum element within a Collection is easy. The following method can be used which can be found within the Collections class. public...
« previous
beginning
next »
Related Links
Collections Forum
JGL vs. Collections Framework
Java Collections Short Course
Java Collections Tutorial
Java Collections Chapter
Collections for JDK 1.1
The Colt Distribution
Historical collection classes--Arrays
Wish List
Features
About jGuru
Contact Us