Post

Section 15. (Java Collection Framework) Udemy - Java Programming Masterclass

Java Collections

Overview

  • just an object that represents a group of objects where there is some relationship for them
  • arrays, lists, vectors, sets, queues, tables, dictionaries and maps
  • They are differentiated by the way the store the objects in memory, how they are accesses and ordered, and whether they allow duplicates and null value s

What’s in the framework, what’s not?

  • Objects who implement they Collection interface
    • except: maps

Collection is the root of the collection hierarchy

  • Everything branches off of the Collection interface
  • alt-text

Collection interface methods

  • alt-text

What’s a Collection Class?

  • The Collections class is not the Collections Framework

Collection Types

List

  • Ordered
  • aka sequence

Queue

  • Ordered
  • Special methods for the first & last elements
  • FIFO / LIFO
  • Stack and Queues

Set

  • Unordered
  • No Duplicates

SortedSet

  • Ordered
  • No Duplicates

Map

  • Stores key,value pairs

Deque

Collection Helper methods

Collections.nCopies(int count, Object o)

  • Similiar to Arrays.fill()
  • Collections has Collections.fill() but it doesn’t work
1
List<Card> king_of_clubs = Collections.nCopies(2, Card.getFaceCard(Card.Suit.CLUB, 'K'));
This post is licensed under CC BY 4.0 by the author.