public class MainClass { public A cont() { return new A() { private int i = 11; public int value() { return i; } }; // Semicolon required in this case } public static void main(String[] args) { MainClass p = new MainClass(); A c = p.cont(); } } interface A { int value(); }