CodeX
Published in

CodeX

A couple of use cases for anonymous classes in Java

Photo by DANNY G on Unsplash

When I first learned about anonymous classes in Java, I didn’t quite see the point. I understood the syntax well enough to recognize anonymous classes in applications of Java’s Abstract Window Toolkit (AWT).

Those didn’t quite seem to make sense to me. You want a particular window to close when a user clicks the Close button? Subclass WindowAdapter anonymously. For example,

--

--

--

Everything connected with Tech & Code. Follow to join our 900K+ monthly readers

Recommended from Medium

Integrate OpenAPI with Jetty

Unity Command Line Build Error “The only standalone target supported is Windows x64 with OpenXR.

Announcing Envoy Mobile

How to Fix the ‘Couldn’t Modify Partition Map’ error on MacOS?

Deploying webserver by creating a High Availability Architecture using AWS CLI

Mastering Kotlin indexed access operator

SuperStarter: Virtue Poker Timelines and IDO Details

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
Alonso Del Arte

Alonso Del Arte

is a composer and photographer from Detroit, Michigan. He has been working on a Java program to display certain mathematical diagrams.

More from Medium

Make your Java comments more informative, actionable

Debugging Java Equals and Hashcode Performance in Production

Understand Multi-Threading in Java — Part II

Java Collections: Why you should use Iterator interface?