lec27March1408

lec27March1408 - boolean isEmpty() int size() • An...

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

View Full Document Right Arrow Icon
Lecture 27 March 27, 2008
Background image of page 1

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

View Full DocumentRight Arrow Icon
ArrayList ArrayList band = new ArrayList() band.add (“Paul”); Band.add(“John”); int location = band.indexOf(“Paul”); Band.remove(location);
Background image of page 2
• An ArrayList is not declared to store a particular type • An Arraylist object dynamically grows and shrinks • Any type of object can be stored in it
Background image of page 3

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

View Full DocumentRight Arrow Icon
ArrayList() boolean add(Object obj) void add(int index, Object obj) Object remove(int index) Object set(int index, Object obj) void clear() boolean contains(Object obj) int indexOf(Object obj) Object get(int index)
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: boolean isEmpty() int size() • An ArrayList is a generatic type – Allows us to the type of data – The compiler will not allow an object to be added unless it’s of this specified type • ArrayList<String> myList = new ArrayList<String>(); • ArrayList<Point> myList = new ArrayList<Point>(); • Declaring the element type of an ArrayList is usually a good idea: – Type-checking – Eliminates the need to cast an object into its true type • In class example …...
View Full Document

This note was uploaded on 04/14/2008 for the course COMP 202 taught by Professor Verbrugge during the Winter '07 term at McGill.

Page1 / 7

lec27March1408 - boolean isEmpty() int size() • An...

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

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