Tuesday, September 25, 2012

Java interfaces support multiple extends

As we have always learnt, a Java class can never extend/inherit more than one class. While this still holds true, very few of us know that a Java "Interface" is capable of  extending/inheriting more than one "interfaces".

  For example:
    interface interface_1{
       // interface definition
    }
    interface interface_2{
      // interface 2 definition
    }

///   and then


    interface A extends interface_1, interface2 {

   }


So, this is a valid interface inheritance in Java. Note that this holds true only in the Interfaces and not Java classes

No comments:

Post a Comment