omar al kababji wrote:No interfaces can only extend other interfaces
interface1 extends interface2
this is the only possible thing to do with interfaces.
however abstract classes, can implement interfaces and they can either provide a definition for the interface methods or leave it for the first concrete class that extends that abstract class.
Yes with regards to inheritance this is true. However it is not only Abstract Classes which can implement interfaces. Concrete classes themselves are also able to implement interfaces, and in doing so are required to fulfill the contract of the methods declared in the interface.
Additionally interfaces are a fine example of polymorphism if the technique of "programming to an interface" is used. In Java it is strongly recommended that any arguments to a parameter for a method should be as general as possible. This ensures among other things, that there is a good degree of flexibility in your code. What it means in code, is that any object maybe passed to your method providing it implements the required interface, so in the future if you have additional Objects with a varying degree of behaviors and attributes they may still be handled by your Method providing they implement the interface.
For example take the following example (tried and tested in Eclipse);
This should produce the following output:
Hope this of use
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com