Introduction to OOP: Chapter 12: Implications of Inheritance [previous] [audio] [real] [text]

Type Conversion in Java

Values in Java (or Object Pascal or Smalltalk or Objective-C) all ``know'' what class they are from - functions are provided to test this.

Once a class type is checked, a cast can be used to convert value.

	Ball aBall = ...;

	if (aBall instanceof BlackBall) {
		BlackBall bball = (BlackBall) aBall;
Intro OOP, Chapter 12, Slide 23