1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types and Exceptions in Java

Connected

Exercise

Working with LinkedList

Now you will create a shopping list as a LinkedList (vs ArrayList) and perform the same types of add/remove of String objects to the shopping list. This allows you to see how LinkedList and ArrayList share the same List interface and are polymorphic in their behavior.

Instructions

100 XP
  • Import LinkedList for use in the application.
  • Construct a new LinkedList of Strings and set the shopList variable to it.
  • Add "eggs" to the end of the shopping list.
  • Add a second "milk" to the beginning of the shopping list.