Java_Assignment_Comparisons
Java_Assignment_Comparisons
1. Array vs Collection:
- Array is a fixed-size data structure that stores elements of the same type.
- Collection is part of the Java Collections Framework and provides dynamic storage.
2. ArrayList vs LinkedList:
- ArrayList offers fast random access; LinkedList is better for frequent insertions/deletions.
3. List vs Set:
- Set does not allow duplicates and may not maintain order (e.g., HashSet).
4. Collection vs Collections:
5. Comparable vs Comparator:
- Comparator defines custom sorting logic outside the class via compare().
- Comparable modifies class; Comparator adds flexibility for different sort logics.