What is the $1 in class file names?

Those are the .class files that hold the anonymous inner classes.

In your example WelcomeApplet.java contains a top-level class (called WelcomeApplet) and an anonymous inner class, which will be stored in WelcomeApplet$1.class.

Note that the exact name of the files holding anonymous inner classes is not standardized and might vary. But in practice I’ve yet to see any other scheme than the one described here.

Value-specific bodies for an enum are also anonymous inner classes:

The optional class body of an enum constant implicitly defines an anonymous class declaration (ยง15.9.5) that extends the immediately enclosing enum type.

Leave a Comment