File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Converting base clas to derived class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Converting base clas to derived class" Watch "Converting base clas to derived class" New topic

Converting base clas to derived class

Jothi Prasadh

Joined: Apr 23, 2006
Posts: 1

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..

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189


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:
subject: Converting base clas to derived class