Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a basic java question

 
Abhi Venu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class A
{
method(){ implmntn 1}
}

class B
{
method(){ implmntn 2}
}

class D
{
method(){ implmntn 3}
}


class myClass needs methods implemented by other three classes ,Not by creating a reference variable of these 3 in my class but by some other way. I know multiple inheritance is not allowed in java...yet i want to know

How can this be done in Java?
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. You either need to create an instance of each class or make the methods static. The latter may not be possible if the method implements an interface method or overrides a method from a super class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic