This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Converting base clas to derived class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Converting base clas to derived class" Watch "Converting base clas to derived class" New topic
Author

Converting base clas to derived class

Jothi Prasadh
Greenhorn

Joined: Apr 23, 2006
Posts: 1
Hi,

I have a class A which has two subclass B and C.A is associated with a class D.but if i want to store the B objects in D.How can i store B/C objects in D..

Thanks,
Anandh
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24061
    
  13

Hi,

Welcome to JavaRanch!

You'll have to be a bit clearer as to what you're asking here; what does "is associated with" mean, exactly?

But perhaps it would help you to know that any method that accepts an A as an argument will automatically accept a B or a C, and any variable of type A can, again, automatically, refer to a B or a C, if you make the assignment.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Converting base clas to derived class
 
Similar Threads
Polymorphism Concepts
The use of Hashtable for synchronization.
HOW WRAPPER CLASSES ADD FUNCTIONALITY
HashMap and HashSet
Serialization doubt