Anonymous inner classes in Java (from Thinking in Java 4th edition) -


i started learning java , there error in line 2: "small cannot resolved type". why?

public class big { public small getsmall() {     return new small() {         void out() {             system.out.println("big small out()");         }     }; }  public static void main(string[] args) {     big b = new big();     small s = b.getsmall();     s.out();     system.exit(0); } 

}

public small getsmall() {     return new small() {         void out() {             system.out.println("big small out()");         }     }; } 

there seems little misunderstanding. when declare anonymous inner class assumed small either interface implementing or class extending. if have small class or interface need import it. if not create one.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -