Have a way to simulate diamond problem with Java [closed]
Have a way to simulate the diamond problem with Java ? With interfaces ?
Thanks, Cel开发者_Go百科so
In Java you can never have a diamond problem. It's designed not to have multiple inheritance.
Diamond problem comes when you have multiple data members and function member with solid definition in the super base class. However, in Java you can only have interface
getting implemented; which never can contain anything other than pure virtual
methods and static const
members (in C++ context).
Java avoids the diamond problem by enforcing single-inheritance for classes and allowing multiple inheritance for interfaces.
It's not really a problem when interfaces form a diamond.
You can get a Javadoc diamond problem, but I guess that's not what you're looking for.
精彩评论