Thursday, July 14, 2011

Java "Dimound" problem

This entry is for programmers if your not a programmer it may not make sense to you.For the rest of you sorry, this was interesting enough that I just had to say it and you will just have to take my word for it

 Java claims that it does not have mutiple inheritance for severel reasons, one of them is to avoid something called "The Dimound Inheritance Problem" or iherting form several classes which overide a common base method and when makeing a call to "base.method()" not knowing which one you called. The remarkable thing is you can still do this in Java WITH INTERFACES. Interfaces can contain constants and when the interface is implemented the constants are "inherited". If I have too interfaces and each one has a constant OF THE SAME NAME but a different value and I then try to access the constant from the implemented class(that is ImplemnetingClass.constend) I get a ambiguis error which I bilive what Sun wanted to avoid in the first place! just something to think about. :) 

2 comments:

  1. As a wise man once said, it's the shoddy carpenter who blames his tools.

    ReplyDelete
  2. LOL! Java claims to be a tool that will not have that problem though I get what your saying.

    ReplyDelete