CMPSC 56 Chapter Notes - Chapter 16: Type Safety, Comparator
Document Summary
Lets you store and access elements as name/value pairs. Gives better performance when inserting/deleting elements from the middle of the collection. Can remember the order in which elements (name/value pairs) were inserted. Can be configured to remember the order in which elements were last accessed. The collections class (java. util. collections) has a sort() method. Arraylist implements the list interface (arraylist is-a list) You can pass an arraylist to a method declared to take list due to polymorphism. Angle brackets means generics i. e. the sort() method uses generics. Note: (not from textbook) you cannot put a subtype where its superclass is expected in a generic. Virtually all code you write that deals with generics will be collection-related code. The point of generics is to let you write type-safe collections. Aka code that makes the compiler stop you from putting a type1 object into a list of type2.