03JavaConstructs

03JavaConstructs - CMSC 132: Object-Oriented Programming II...

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

View Full Document Right Arrow Icon
1 CMSC 132: Object-Oriented Programming II Object-Oriented Programming & Java Language Constructs Department of Computer Science University of Maryland, College Park
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Review of Java Language Constructs Basic elements Primitive types, variables, constants, operators If-else, switch, while, for Classes Object instances Creating objects with new Object references The null reference Instance data, class (static) data Methods Parameters, return values, polymorphism
Background image of page 2
3 Review of Java Language Constructs Inheritance Base class, derived class, super Method overriding (vs. overloading) Abstract methods Up- and down-casting , getClass() , instanceof avoid overuse of these. .. leads to bad designs Interfaces 1D Arrays Creating, indexing Exceptions Try-catch blocks
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Iterator Interface Iterator Common interface for all Collection classes Used to process all elements in collection Properties Can remove current element during iteration Works for any collection
Background image of page 4
5 Iterator Interface Interface public interface Iterator { boolean hasNext ( ); Object next ( ); void remove ( ); // optional, called once per next( ) } EXAMPLE: IteratorExample
Background image of page 5

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

View Full DocumentRight Arrow Icon
Iterable Interface Includes just one prototype: Iterator<T> iterator(); Most collections in the Java Collections Framework implement Iterable 6
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/12/2012 for the course CMSC 132 taught by Professor Padua-perez during the Fall '08 term at Maryland.

Page1 / 20

03JavaConstructs - CMSC 132: Object-Oriented Programming II...

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