CSE 115 Lecture 24: 03.25.16 lecture notes

37 views3 pages

Document Summary

A collection object can store arbitrarily many (references to) objects. We will first learn to become users of collections. Next semester we will learn how to build a collection java. util. collection interface. All collection classes in java are subtypes of the java. util. collection interface. E is a type variable, and denotes the element type of the collection: Arraylist permits duplicates allows client to control order of elements. Hashset does not permit duplicates does not allow client to control order of elements. To declare a variable of type hashset of string: To create a hashset of string object, and assign its reference to the variable declared above: names = new hashset(); How would you declare x" to be a variable whose type was arraylist of. Actionlistener: arraylist x, actionlistener x, actionlistener[] x, arraylist x = new actionlistener(); answer: a. arraylist x; To add a string to the hashset: names. add( fred ); To remove a string from the hashset: names. remove( fred );

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions