CodeX
Published in

CodeX

Finer points of Java: the difference between nested, inner and anonymous classes

Photo by CHUTTERSNAP on Unsplash

A Java project usually has several classes, each defined in its own source file by itself. Sometimes, though, it’s convenient to put one Java class inside another. Here’s a toy example:

package org.example;public class EnclosingClass {    class EnclosedClass {

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store