interface TestA {
String toString();
}
public class Test {
public static void main(String args[]) {
System.out.println(new TestA() {
public String toString() {
return "test";
}
});
}
}
This will print test
as output.
- Can anyone explain how this works?
- When I change the method name
toString()
asprintString
, it will print only a memory address.Explain how it works.