View Single Post
  #6 (permalink)  
Old 01-19-2008, 03:47 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Casting
Hello java_fun2007.

I forgot to tell you about casting. Lets say that you have defined some method in the DVD class that is not inherited or overridden from its super class, but you need to use it. For this you can use casting. When you cast you must use brackets and class name of the class you need. For example:
Code:
Vedio media = new DVD(); if (media instanceof DVD){ // now we know it's an DVD and we can cast DVD dvd = (DVD) media; // now you can use dvd with all the methods and attributes of a real DVD instance. }
I hope this helped. This is pretty important stuff.
__________________
If your ship has not come in yet then build a lighthouse.
Reply With Quote