Why static and default methods are added to interfaces in Java? -


I use Java but I have a better background with C #. I am reading Java and the methods in the interface. I think that I understand how the default methods will be useful in the interface. For example, we have extension methods in C #, with the help of language designers, it is one thing that they do not have Where , You can add new ways to freely interface such as Select etc. Where lambda quote can be used without destruction. That's why the default methods in the Java interface can help in the same way.

But when it comes to stable methods in the Java interface, this is where I am, it will not be certain how useful it will be. What no one can explain to me why it is added High methods to interface and in which case they are useful for the developer I do that it would also hear default method There are different reasons for what I have mentioned.

But when it comes to static methods in the Java interface, this is the place Where I can not believe how it will be useful.

This case separately rejects the "utility" category whose sole purpose is for all static methods connected to a stable interface.

There is always an example which meditates for me - if permission is given in a steady manner on the intersection from the beginning, then this whole class will not be necessary and static methods only archive Interface (which can be understood as they work on all archive types).

Of course, the rear compatibility means that we can not be away from designing this way in Adi, but that means library design in the future can take care of it and hopefully its reason A little cleaner APIs from

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -