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

  • Home
  • SEARCH
  • 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 40643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:03:21+00:00 2026-05-10T15:03:21+00:00

What is the main difference between an inner class and a static nested class

  • 0

What is the main difference between an inner class and a static nested class in Java? Does design / implementation play a role in choosing one of these?

  • 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. 2026-05-10T15:03:21+00:00Added an answer on May 10, 2026 at 3:03 pm

    From the Java Tutorial:

    Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes.

    Static nested classes are accessed using the enclosing class name:

    OuterClass.StaticNestedClass 

    For example, to create an object for the static nested class, use this syntax:

    OuterClass.StaticNestedClass nestedObject = new OuterClass.StaticNestedClass(); 

    Objects that are instances of an inner class exist within an instance of the outer class. Consider the following classes:

    class OuterClass {     ...     class InnerClass {         ...     } } 

    An instance of InnerClass can exist only within an instance of OuterClass and has direct access to the methods and fields of its enclosing instance.

    To instantiate an inner class, you must first instantiate the outer class. Then, create the inner object within the outer object with this syntax:

    OuterClass outerObject = new OuterClass() OuterClass.InnerClass innerObject = outerObject.new InnerClass(); 

    see: Java Tutorial – Nested Classes

    For completeness note that there is also such a thing as an inner class without an enclosing instance:

    class A {   int t() { return 1; }   static A a =  new A() { int t() { return 2; } }; } 

    Here, new A() { ... } is an inner class defined in a static context and does not have an enclosing instance.

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

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You might use something like (pseudo-code): counting query: $n =… May 11, 2026 at 2:08 pm
  • added an answer The built-in wceload has no provision to do that. You… May 11, 2026 at 2:08 pm
  • added an answer How can you be sure it's an exception, when you've… May 11, 2026 at 2:08 pm

Related Questions

What is the main difference between int.Parse() and Convert.ToInt32() ? Which one is to
What is the main difference between StringBuffer and StringBuilder ? Is there any performance
What are the main differences between a Linked List and a BinarySearchTree? Is BST
What are the main differences among them? And in which typical scenarios is it
I've been doing some experiments with the Cell processor in a PS3 that I
Does an asynchronous call always create a new thread? What is the difference between
I know Googling I can find an appropriate answer, but I prefer listening to
I have several ASP:TextBox controls on a form (about 20). When the form loads,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.