Static methods and their overriding

No, you’re not overriding anything – you’re just hiding the original method.

It’s unfortunate that Java allows you to call a static method via a reference. Your call it more simply written as:;

Importantly, this code would still call the original version in stat13:

public static void showStat(stat13 x)
showStat(new next());

In other words, the binding to the right method is done at compile-time, and has nothing to do with the value of x – which it would normally with overriding.

Leave a Comment