6: Collections/GenericsHomepage  « Java6 Certification « 6: Collections/Generics

We start this section by looking at the various types of collections and their corresponding interfaces and which type of collection is suitable for specific types of data. We then look at usage of the Comparable interface. After this we look at the equals() method of the Object class which only ever returns true when the reference variables refer to the same object which isn't helpful when we want our collections sorted and stored dependent upon fields in the collection. So in this lesson we look at correct and incorrect overrides of corresponding equals() and hashCode() methods and explain the difference between == and the equals() method. Generics were introduced with Java6 and in this lesson we look at the reasons for doing this. We then look at usage of type parameters in class/interface declarations, instance variables, method arguments, and return types. We finish the lesson by looking at generic methods as well as methods that make use of wildcard types. We finish the section by looking at array and list manipulation using the java.util package, usage of the java.util.Comparator and java.lang.Comparable interfaces for sorting collections and the effect of natural ordering of primitive wrapper classes and java.lang.String on sorting.

Lets take a look at the points outlined at the Oracle Website for this part of the certification.

  • Section 6: Collections / Generics

    1. Given a design scenario, determine which collection classes and/or interfaces should be used to properly implement that design, including the use of the Comparable interface.

    2. Distinguish between correct and incorrect overrides of corresponding hashCode and equals methods, and explain the difference between == and the equals method.

    3. Write code that uses the generic versions of the Collections API, in particular, the Set, List, and Map interfaces and implementation classes. Recognize the limitations of the non-generic Collections API and how to refactor code to use the generic versions.

    4. Develop code that makes proper use of type parameters in class/interface declarations, instance variables, method arguments, and return types; and write generic methods or methods that make use of wildcard types and understand the similarities and differences between these two approaches.

    5. Use capabilities in the java.util package to write code to manipulate a list by sorting, performing a binary search, or converting the list to an array. Use capabilities in the java.util package to write code to manipulate an array by sorting, performing a binary search, or converting the array to a list. Use the java.util.Comparator and java.lang.Comparable interfaces to affect the sorting of lists and arrays. Furthermore, recognize the effect of the "natural ordering" of primitive wrapper classes and java.lang.String on sorting.

6.1 Collection Usage

In our first lesson within this section we look at the various types of collections and their corresponding interfaces and which type of collection is suitable for specific types of data. We then look at usage of the Comparable interface.

6.2 Overriding the equals() & hashcode() Methods

The equals() method of the Object class only ever returns true when the reference variables refer to the same object which isn't helpful when we want our collections sorted and stored dependent upon fields in the collection. So in this lesson we look at correct and incorrect overrides of corresponding equals() and hashCode() methods and explain the difference between == and the equals() method.

6.3-6.4 Generic Types

Generics were introduced with Java6 and in this lesson we look at the reasons for doing this. We then look at usage of type parameters in class/interface declarations, instance variables, method arguments, and return types. We finish the lesson by looking at generic methods as well as methods that make use of wildcard types.

6.5 Using The Collections Framework

In our final lesson within this section we look at array and list manipulation using the java.util package, usage of the java.util.Comparator and java.lang.Comparable interfaces for sorting collections and the effect of natural ordering of primitive wrapper classes and java.lang.String on sorting.

Related Java6 Tutorials

Collections/Generics - Collections Overview
Collections/Generics - Sets
Collections/Generics - Lists
Collections/Generics - Queues
Collections/Generics - Maps
Collections/Generics - Generics
OO Concepts - The Object Superclass

go to home page Java6 Tutor Homepage go to home page Top

All the Java6 Certification Collections/Generics lessons are listed below. Click a link to go to that lesson.

6: Collections/Generics

6.1 Collection Usage

6.2 Overriding equals() & hashcode()

6.3-6.4 Generic Types

6.5 Using The Collections Framework