Please check the Java code below:
public class Test { public static void main(String arg[]) throws Throwable { Test t = new Test(); System.out.println(t.meth().s);
As you can see, I created the interface anonymously. When I access the interface variable directly, it will show "Old value".
t.meth (). s => "Old value"
Accessing it through the getVal () method returns the correct values,
t.meth (). getVal () => "String implementation"
I donβt understand how this code works, can someone explain this to me?
java interface anonymous-class
sprabhakaran
source share