Loading topic
outer.new Inner() creates an inner object attached to a chosen outer object. Outer.this lets the inner object refer back to that outer object. It assumes you can read basic Java classes, know the5 min readOuter.this. Here you will learn how Java decides which declaration a plain name refers to wh6 min readRunnable and Comparator. It builds on the earlier chapters on local classes and variable cap6 min readComparator and Runnable work. Here you will compare the two ways to write a one-off implementation. You will see where they beha6 min readOuter.Inner and outer.new Inner() without stopping, you are ready.5 min readOuter.this. It also assumes you know what garbage collection reachability means: an object stays alive while a chain of references leads to it from a GC root, such as a static field or a running thread.5 min readjavac, javap, and a little reflection, so you need JDK 11 or later. 7 min readOuter.this and outer.new Inner() syntax, effectively final capture, and how lambdas replace single-method anonymous classes. Here we turn that knowledge into a decision procedure.5 min read