Skip to content

Commit edb9158

Browse files
author
tugul
committed
java.util.Arrays is helper class
1 parent 767b705 commit edb9158

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

collections/ArrayVsArrayList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* Dimension: Array can be multi-dimensional while ArrayList is only single dimensional
99
* Primitive: ArrayList can't store primitives, instead can store their wrapper objects
1010
* Generics: ArrayList supports generics, so it is type-safe
11-
* Adding an element: Array element is added through asignment operator, while ArrayList use add() method
12-
* Length: Array has length variable while ArraList has size() method
11+
* Adding an element: Array element is added through assignment operator, while ArrayList use add() method
12+
* Length: Array has length variable while ArrayList has size() method
1313
* Performance: Array is faster while ArrayList is bit slower, especially when comparing
1414
* Sorting:
1515
* Array : Arrays.sort(T[] a);

collections/README.md

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1-
Collections framework has four main data structure types (list, set, queue and map).
2-
List, set and queue interfaces extends Collection interface which extends Iterable interface.
1+
# Collections framework
2+
Collections framework has four main data structure types which are **list**, **set**, **queue** and **map**.
3+
``List``, ``Set`` and ``Queue`` interfaces in ``java.util`` extends ``java.util.Collection`` interface which extends ``java.lang.Iterable`` interface.
34

4-
##### 1. List — Ordered collection of elements that can duplicate
5-
- ArrayList: Standard re-sizable list.
6-
- LinkedList: implements both List and Deque. Can easily add/remove from beginning or end.
7-
- Vector: Older version of ArrayList, thread-safe.
8-
- Stack: Older last-in, first-out class, newer version ArrayDeque is more flexible
5+
## Main data structure types
6+
### 1. **List** — Ordered collection of elements that can duplicate
7+
- ``ArrayList``: Standard re-sizable list.
8+
- ``LinkedList``: implements both ``List`` and ``Deque``. Can easily add/remove from beginning or end.
9+
- ``Vector``: Older version of ``ArrayList``, thread-safe.
10+
- ``Stack``: Older last-in, first-out class, newer version ``ArrayDeque`` is more flexible
911

10-
##### 2. SetDoes not allow duplicates
11-
- HashSet: Uses hashcode() to find unordered elements.
12-
- TreeSet: implements NavigableSet which extends SortedSet. Does not allow null values.
12+
### 2. **Set**Does not allow duplicates
13+
- ``HashSet``: Uses ``hashcode()`` to find unordered elements.
14+
- ``TreeSet``: implements ``NavigableSet`` which extends ``SortedSet``. Does not allow null values.
1315

14-
##### 3. QueueOrders elements for processing
15-
- LinkedList: Can easily add/remove from beginning or end.
16-
- ArrayDeque: First-in, first-out or last-in, first-out. Does not allow null values.
16+
### 3. **Queue**Orders elements for processing
17+
- ``LinkedList``: Can easily add/remove from beginning or end.
18+
- ``ArrayDeque``: First-in, first-out or last-in, first-out. Does not allow null values.
1719

18-
##### 4. MapMaps unique keys to values
19-
- HashMap: Uses hashcode() to find keys, allows null key
20-
- TreeMap: Sorted map. Does not allow null keys.
21-
- HashTable: Older version of HashMap. Does not allow null keys or values.
20+
### 4. **Map**Maps unique keys to values
21+
- ``HashMap``: Uses ``hashcode()`` to find keys, allows null key
22+
- ``TreeMap``: Sorted map. Does not allow null keys.
23+
- ``HashTable``: Older version of ``HashMap``. Does not allow null keys or values.
2224

23-
Sorting:
24-
- Collections.sort(List\<T extends Comparable> list)
25-
- Collections.sort(List\<T> list, Comparator comparator)
26-
- Use TreeMap to sort Map by key or value
25+
## Sorting
26+
- ``Collections.sort(List\<T extends Comparable> list)``
27+
- ``Collections.sort(List\<T> list, Comparator comparator)``
28+
- Use ``TreeMap`` to sort ``Map`` by key or value
29+
30+
## Helper classes
31+
### ``java.util.Arrays``
32+
It is a helper class for common unitility tasks on manipulating arrays such as _sorting_ and _searching_ in arrays
33+
34+

0 commit comments

Comments
 (0)