2 ms·
That's right, I forgot a method parameter: jshell> class Foo { void foo(Object o) { System.out.println("Super"); } } | created class Foo jshell> class
by frant-hartm 7y ago
That's right, I forgot a method parameter:
jshell> class Foo { void foo(Object o) { System.out.println("Super"); } }
| created class Foo
jshell> class Bar extends Foo { void foo(Integer i) { System.out.println("Sub"); } }
| created class Bar
jshell> Foo f = new Bar();
f ==> Bar@7f9a81e8
jshell> Integer i = 1;
i ==> 1
jshell> f.foo(i)
Super
jshell> ((Bar)f).foo(i);
Sub