This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface

 
Mike Shn
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it possible in Java for interface to use Multiple inheritance?
 
Dave Vick
Ranch Hand
Posts: 3244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike
There is no multiple inheritance in Java. However, using interfaces you can simulate it. Interfaces let you extend multiple interfaces but not to extend multiple classes.
Put another way:
Both a class or an interface can inherit from more than one interface. A class, however, can only inherit from one other class.
Check out the following code:

hope that helps a little bit
 
Shivaji Marathe
Ranch Hand
Posts: 203
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually it is also possible to write code where one interface extends several others. Code like this compiles at least in JDK 1.3.1
Such as
interface InterBase extends InterSuper, InterAnother {
// methods here.
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic