Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting base clas to derived class

 
Jothi Prasadh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic