Nation Chirara

Greenhorn
+ Follow
since Mar 14, 2015
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Nation Chirara

Stephan van Hulst wrote:The reason is because of the history of the Java language.

Static methods in interfaces were only added in Java 8. By that time, many classes were written that implement existing interfaces. When the developers allowed for static methods to be added to interfaces, they wanted to make sure that existing classes didn't suddenly break because the interface that they implemented had added a static method that happens to have the same name as a method in the class.

If interfaces had supported static methods from the very beginning, the first snippet of code probably would have caused a compilation error as well.



This drove the point home, I got you thanks!
5 years ago
Why does this compile? Am I not trying to override a static method here ?



As this does not compile.

5 years ago
Thank you Ritchie for the informative answer, now I got it all.
5 years ago
Why would this fail to compile?



My thinking is that the compiler "must know" that 10 fits into float and d wont take another value because it is final.

where as this compiles?

5 years ago