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 6946581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:35:00+00:00 2026-05-27T13:35:00+00:00

The Java Tutorial says that the static nested classes are accessed by using the

  • 0

The Java Tutorial says that the static nested classes are accessed by using the name of the enclosing class like new EnclosingClassNameHere.StaticNestedClassNameHere()

Why would i want to create an instance of a static class at all? Can somebody please explain?

  • 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-27T13:35:01+00:00Added an answer on May 27, 2026 at 1:35 pm

    "static" in this case can be misleading. What it really means is that the class can exist independently. Non-static inner classes can’t exist without an instance of the enclosing class.

    IMO, when you start using an inner class outside the class that it’s in, you need to consider moving it and making it its own top level class. There are very few cases where the relationship between the classes is so tightly coupled that you need to keep it as an inner class.

    In your code example:

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

    You’re creating a stand-alone instance of StaticNestedClass.

    If it wasn’t static, you couldn’t do that. You could only create instances of StaticNestedClass() from an instance of OuterClass.

    If you moved it to its own .java file, you could treat it nearly identically:

    StaticNestedClass notNestedAnymore = new StaticNestedClass();
    

    As to your real question: Why would you want to create an instance of it? For the same reason that you create instances of any class – it does some piece of work that you need.

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

Sidebar

Related Questions

http://download.oracle.com/javase/tutorial/java/javaOO/nested.html says that static nested classes should be accessed this way: OuterClass.StaticNestedClass nestedObject =
The Java Tutorial says that since an inner class is associated with an instance
The Java for C++ programmers tutorial says that (highlight is my own): The keyword
Is there any recommended Java application profiling tutorial? I am now using JProfiler and
Please provide a good, thorough tutorial about Java class loading , focusing on how
Why this line doesn't work? import static java.nio.file.AccessMode.*; Eclipse says: The import java.nio.file cannot
I just had a look at Suns Java tutorial, and found something that totally
I am following this tutorial, I'm using netbeans 6.5.1 http://www.netbeans.org/kb/docs/java/gui-db-custom.html When I get to
First off, rest assured that I've read every Oracle Java article & tutorial about
I am fairly new to Java programming and was following a tutorial located here:

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.