Reputation: 57
Why was this(Allowance of Static Methods definition) added in java development kit version 1.8 ?
Whats the use of adding this functionality ?
Why was it needed ?
I know those methods can be called with Interface.method() in case of any class which implements this interface !
Why did they need to add this :?
I mean if you can define static methods in interface its kind of similar to abstract class ? Isn't It ?
Correct me if i am wrong !!!!
I don't claim to be rite :)
Upvotes: 0
Views: 765
Reputation: 691655
It wasn't really a need to have this. After all, we have survived since the beginning of Java without them. But it's a nice to have. It's quite frequent to have an interface (Collection, for example), with another class containing static utility methods dealing with this interface (Collections, for example).
Putting the utility methods in the interface makes finding these utility methods easier, and there is no reason not to allow static methods in interfaces, so why not allowing them.....
Upvotes: 1