CMPSC 56 Chapter Notes - Chapter 16: Type Safety, Comparator

39 views3 pages
29 Oct 2017
School
Course
Professor

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents