The s
variable declared in the interface is entirely separate from the s
variable you've declared in your anonymous inner class.
Interface variables are really just designed to be constants - they aren't part of the API each implementation needs to provide. In particular, they're implicitly static and final.
From the JLS section 9.3:
Every field declaration in the body of an interface is implicitly public, static, and final. It is permitted to redundantly specify any or all of these modifiers for such fields.
The fact that you've accessed the field via an implementation instance is irrelevant - this code:
System.out.println(t.meth().s);
is effectively:
t.meth();
System.out.println(TestInter.s);
I would strongly encourage you to avoid using variables in interfaces except for genuine constants... and even then, only where it really makes sense. It's not clear what you're trying to achieve, but declaring a field in an interface isn't a good way forward IMO.