Lesson Thursday

So far, you have learned a little about Objects and primitive types in Java, as well as Collection classes such as ArrayList and HashMap.

Java, as a language, is large in size and full featured, and so these are not, by any means, the only types of data that exist. Next to classes, there are interfaces (more on that soon), enums (that hold constants, i.e variables that cannot be changed), and Singletons (An object where only one can exist at any given time.),

Especially where collecting and organizing data is concerned, there are many other Collection data structures that can very useful and powerful.

Collection as a class generally implements methods such as add, remove, contains, isEmpty, and more. This means that all collection types will have access to the above methods, but unique collection types also have specific methods and properties as well. We can also apply sorting and finding methods to collection classes.

Collection Classes:

  • Set: Doesn't allow duplicates. Using a Set can be useful if you are trying to restrict a collection to unique data.

  • List: Can contain duplicates and elements are ordered. Examples of List include ArrayList, or LinkedList. Both are types of Lists, but they vary in how they are implemented and what they can do.

  • Queue: Typically order elements in FIFO order (First In, First Out) except exceptions like PriorityQueue.

  • Deque: (Pronounced like "deck, short for Double Ended Queue) Elements can be inserted and removed at both ends. Allows both LIFO (Last In, First Out) and FIFO.

  • Map: Contains Key value pairs. Doesn't allow duplicates. Example implementation are HashMap and TreeMap.

If you are interested in learning more about different kinds of Java Collection Classes and Data structures, you might take a peek at this tutorial, or review many of the in-depth lessons on this site.