WDD_lec_06 - Web Design & Development Lecture 6...

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

View Full Document Right Arrow Icon
Lecture 6
Background image of page 1

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

View Full DocumentRight Arrow Icon
Collections
Background image of page 2
Collections Built-in support for collections Similar to STL in C++ Collection type Sequence/Set Example ArrayList Map type Hashtable/dictionary Example HashMap Collections store references to objects Use inheritance and interfaces Read http://java.sun.com/docs/books/tutorial/collections
Background image of page 3

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

View Full DocumentRight Arrow Icon
Collection Design All classes provides almost same methods get(), size(), isEmpty()… Easy learning curve for using Collections Implemented as reference to Object Similar to using a void * in C Require a cast back (down casting) to the actual type Example String element = (String)arraylist.get(i) Remember, Java checks all casts at run-time
Background image of page 4
Basic messages constructor() Creates a collection with no elements int size() Number of elements in the collection boolean add() Add a new reference/element at the end of the collection Returns true is the collection is modified. iterator()
Background image of page 5

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

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

Page1 / 22

WDD_lec_06 - Web Design & Development Lecture 6...

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

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