Full Fledged Multiple Inheritance in Java 8 -


It seems that Java 8 is fully down as a simple framework, which is using fixed and default methods on the interface.

It is always possible to misuse and write its stupid code, but these new features are quite a lot Easy, even if the designers of the language had to stay away from it.

Is it simple implementation of multiple heritage, use of interface as base classes, or language misuse? Have the Java designers gone far enough to allow this?

  Package pseudo-military exercises; Import java.util.HashMap; Intangible class instenams & lt; T, T2 & gt; {Hashmap and Object, Object & gt; Example = New Hashmop & lt; Object, object & gt; (); Create Essence T2 Mom's Instance (); T2 getMembersInstance (T this object) {if (! Instances.containsKey (this object)) instances.put (thisObject, createMembersInstance ()); Return (T2) example .get (this object); }} Interface A {class member {int x; // just an example of an inheritable member) Instancemap & lt; A, A. Members & gt; Example map = new instasemp & lt; A, A. Members & gt; () {a. Make Members Mom's Instance () {New A Member (); }}; Default a. This member (A) () {return instanceMap.getMembersInstance (this); } Default intex () () this IA (). X; // // Example of a legacy recipient only) Default Zero setX (int x) {thisA () X = x; // Just an example of a legacy setter}} Interface B {class member {int y; // just an example of an inheritable member) Instancemap & lt; B, B, nummer & gt; InstanceMap = New Instreams & lt; B, B.Members & gt; () {B. Create MembersMombers Instance () {New bemail ();}}; Default B.Members thisB () {returnMapMap.getMembersInstance (this); } Default intermediate () return {thisB ()} y% 10; // Only an example of inheritable function} Default zero increment (int x) {thisB () Y + = x; // Simply an example of Inheritmus function}} CC applies A, B {} public class Example 04 The most multidimensional {public static zero main (string [] args) {cc = 1 = new; Cc2 = new c (); C1.setX (5); c2.setX (3); Println (c1.getX ()); // print system 5. Out.printLine (c2.getX ()); // print 3 c1.incrementY (99); Println (c1.getYLastDigit ()); // print9}}   

///////////////////////////////// //////////////////

Or for one of the other options:

  Interface A {class members {public int X; // Just one example is a legacy member zero showX () {System.out.println (x); } // An example of just a translucent work}} instasemp & lt; A, A. Members & gt; Instasemap = new instancem & lt; A, A. Members & gt; () {a. Make Members Mom's Instance () {New A Member (); }}; Default a. Get the Member () {Return Example Map.getMembersInstance (this); }} Interface B {class member {int y; // just an example of an inheritable member) instenams & lt; B, B, nummer & gt; instanceMap = new instasemap & lt; B, B.Members & gt; () {B. Create MembersMombers Instance () {new B-member ();}}; Default b. Millers getB () {return instanceMap.getMembersInstance (this); }} Class C applies A, B {} public square Example 04 Most Multiplexing {Public Stable Zero Main (String [] Args) {CC1 = New C); Cc2 = new c (); C1.getA () X = 5; C2.getA () X = 3; c1.getA () showX () .; // print5c2.getA () ShowX (); // print3c 1.getB (). Y = 99; System.out.println (c1.getB () .w% 10); // print 9}}  

Applying the interface is not legacy It is as easy as .

What if someone applies both of your interfaces but does a different implementation than the default?

Not so, this is not a multiple legacy, it's just one way to write your code, no one really depends on applying their own version of the default methods, that means that this is the people Depending on whether they are actually not using the interface, because they are able to implement their own methods instead of default, but if they actually do this then your "multiple lineage Nukrm "does not work

I do if I consider the abuse of language.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -