ArrayList
, LinkedList
.HashSet
, TreeSet
.PriorityQueue
, LinkedList
.HashMap
, TreeMap
.ArrayList
: Resizable-array implementation of List
.LinkedList
: Doubly-linked list implementation of List
.HashSet
: Implements Set
using a hash table.TreeSet
: Implements Set
using a tree.HashMap
: Hash table based implementation of Map
.TreeMap
: Red-black tree based implementation of Map
.ArrayList<String>
.ConcurrentHashMap
.add(E element)
, addAll(Collection<? extends E> c)
.remove(Object o)
, clear()
.get(int index)
, contains(Object o)
.Collections.sort(List<T> list)
.
List<String> list = new ArrayList<>();
list.add("Java");
list.add("Python");
list.add("C++");
for (String lang : list) {
System.out.println(lang);
}
Map<String, Integer> map = new HashMap<>();
map.put("one", 1);
map.put("two", 2);
System.out.println(map.get("two")); // prints 2
The Java Collections Framework provides powerful tools for managing collections of objects efficiently, essential for a wide range of Java applications.