Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1029077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:29:13+00:00 2026-05-16T12:29:13+00:00

What is the use of an inner class in a Java server side application?

  • 0

What is the use of an inner class in a Java server side application? Please explain the benefits other than Swing component containment hierarchy using inner class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:29:13+00:00Added an answer on May 16, 2026 at 12:29 pm

    The benefits of anonymous inner classes are exactly the same as for Swing; i.e. they allow you to implement callbacks without the “programming overhead” of separate class file.

    Of course, this is all syntactic sugar. The compiled code for (and performance of) the two approaches are pretty much the same. Indeed, the JVM makes no real distinction between regular and inner / nested classes.

    All of the inner/outer scoping stuff is resolved at compile time and translated into a hidden constructor parameter and a hidden variable in the inner instance that refers to the outer instance. You can simulate this all yourself in non-nested classes by coding explicit parameters / variables. Hence it is syntactic sugar.

    The only thing that you can do with inner classes that you cannot do with separate classes is access private members. To achieve this using separate classes you would need to change the relevant private members to package private. But I’d still classify that as syntactic sugar … or close enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Java 6. I'm having trouble getting my inner class to use the
I wonder why smalltalk doesn't make use of java-style inner class. This mechanism effectively
Why cant JLabel in java swing be declared inside the inner class like JMenu
I have a java class that I use to create a text file from
I'm trying to use CDI for my JSF/Java EE application. I have the following
Possible Duplicate: Use of class definitions inside a method in Java Can we have
Is there any way to initialize anonymous inner class in Java? For example: new
I have a java class: it.eng.ancona.view.RuoliView$TabElaborazioneFattureValidazione$ElencoDettaglioElaborazioneFattureValidazione$RigaElencoDettaglioElaborazioneFattureValidazione It's so long for multiple inner class. If
I use OpenJPA 2.1 on WebSphere Application Server 8. I have a bidirectional oneToMay
There are some cases in Java where an inner class extends an outer class.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.