0% found this document useful (0 votes)
6 views4 pages

Java Data Structures Overview and Methods

The document outlines various Java inbuilt data structures, including List, Set, Map, Queue, Deque, Stack, TreeMap, TreeSet, EnumMap, EnumSet, Concurrent Collections, BitSet, WeakHashMap, IdentityHashMap, Properties, and Arrays Utility. Each structure is defined along with its common methods, highlighting their functionalities and use cases. This serves as a comprehensive guide for understanding and utilizing Java's collection framework.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Java Data Structures Overview and Methods

The document outlines various Java inbuilt data structures, including List, Set, Map, Queue, Deque, Stack, TreeMap, TreeSet, EnumMap, EnumSet, Concurrent Collections, BitSet, WeakHashMap, IdentityHashMap, Properties, and Arrays Utility. Each structure is defined along with its common methods, highlighting their functionalities and use cases. This serves as a comprehensive guide for understanding and utilizing Java's collection framework.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Inbuilt Data Structures and Their Methods

1. List Interface (ArrayList, LinkedList, Vector, Stack)

Definition: A List is an ordered collection that allows duplicate elements. Elements can be accessed by their integer

index.

Common Methods:

- add(E e): Add element to end

- add(int index, E e): Add at index

- get(int index): Get element

- set(int index, E e): Replace element

- remove(index/object): Remove element

- indexOf(Object o), contains(Object o)

- size(), isEmpty(), clear(), iterator()

2. Set Interface (HashSet, LinkedHashSet, TreeSet)

Definition: A Set is a collection that does not allow duplicate elements.

Common Methods:

- add(E e), remove(Object o)

- contains(Object o)

- isEmpty(), size(), clear()

- iterator()

3. Map Interface (HashMap, TreeMap, LinkedHashMap, Hashtable)

Definition: A Map is an object that maps keys to values. Keys must be unique.

Common Methods:

- put(K, V), get(K)

- remove(K), containsKey(K), containsValue(V)

- keySet(), values(), entrySet()


Java Inbuilt Data Structures and Their Methods

- isEmpty(), size(), clear()

4. Queue Interface (LinkedList, PriorityQueue, ArrayDeque)

Definition: A Queue is a collection designed for holding elements prior to processing, typically in FIFO order.

Common Methods:

- add(E), offer(E)

- peek(), element()

- poll(), remove()

5. Deque Interface (ArrayDeque, LinkedList)

Definition: A Deque (Double-Ended Queue) allows insertion and removal of elements from both ends.

Common Methods:

- addFirst(E), addLast(E)

- removeFirst(), removeLast()

- peekFirst(), peekLast()

- offerFirst(E), offerLast(E)

- pollFirst(), pollLast()

6. Stack ([Link])

Definition: A Stack is a last-in, first-out (LIFO) data structure that extends Vector.

Common Methods:

- push(E), pop()

- peek(), isEmpty()

- search(Object o)

7. TreeMap & TreeSet (Sorted Collections)


Java Inbuilt Data Structures and Their Methods

Definition: TreeMap and TreeSet are sorted versions of Map and Set, backed by red-black trees.

TreeMap Methods:

- firstKey(), lastKey(), ceilingKey(), floorKey()

- subMap(), tailMap()

TreeSet Methods:

- first(), last(), ceiling(), floor()

- headSet(), tailSet()

8. EnumMap / EnumSet

Definition: Specialized map and set implementations for use with enum types.

Examples:

- [Link](), EnumMap<Enum, Value>()

9. Concurrent Collections

Definition: Thread-safe collections provided by [Link] for use in multithreaded environments.

Examples:

- ConcurrentHashMap: Thread-safe map

- CopyOnWriteArrayList: Safe for concurrent reads

- LinkedBlockingQueue, PriorityBlockingQueue: Blocking queues

10. BitSet

Definition: Represents a vector of bits that grows as needed. Useful for compact storage of boolean flags.

Methods:

- set(index), clear(index), get(index)


Java Inbuilt Data Structures and Their Methods

- and(), or(), xor()

11. WeakHashMap

Definition: A Map where keys are held using weak references, allowing them to be garbage-collected when no longer in

use.

12. IdentityHashMap

Definition: A Map that compares keys using reference-equality (==) instead of equals().

13. Properties

Definition: A subclass of Hashtable used to maintain configuration data as key-value pairs, typically loaded from files.

Methods:

- load(InputStream), getProperty(String), setProperty()

14. Arrays Utility

Definition: Utility class for array manipulation.

Methods:

- [Link](), [Link]()

- [Link](), [Link]()

You might also like