cheat-sheet - CSE 143 MIDTERM EXAM CHEAT SHEET Constructing...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
***** CSE 143 MIDTERM EXAM CHEAT SHEET ***** Constructing Various Collections List <Integer> list = new ArrayList <Integer>(); Queue <Double> queue = new LinkedList <Double>(); Stack <String> stack = new Stack <String>(); Set <String> words = new HashSet <String>(); Map <String, Integer> counts = new TreeMap <String, Integer>(); Methods Found in ALL collections (Lists, Stacks, Queues, Sets, Maps) clear() removes all elements of the collection equals( collection ) returns true if the given other collection contains the same elements isEmpty() returns true if the collection has no elements size() returns the number of elements in the collection toArray() returns an array of the elements in this collection toString() returns a string representation such as "[10, -2, 43]" Methods Found in both Lists and Sets (ArrayList, LinkedList, HashSet, TreeSet) add( value ) adds value to collection (appends at end of list) contains( value ) returns true if the given value is found somewhere in this collection iterator() returns an Iterator object to traverse the collection's elements
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 12/17/2011.

Page1 / 2

cheat-sheet - CSE 143 MIDTERM EXAM CHEAT SHEET Constructing...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online