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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:23:02+00:00 2026-05-18T11:23:02+00:00

I am wondering how come I can reach inner class directly from outer type

  • 0

I am wondering how come I can reach inner class directly from outer type as if it is a static member like :

public class Hello {
    public class UnderHello
    {
        void runObject()
        {

        }
    }
}

So when I reach the UnderHello

public class SomeOtherClass {
    public void ClickOnMe()
    {
            Hello.UnderHello //this is shown by auto-complete
    }
}

I was expecting something like this :

public class SomeOtherClass {
    public void ClickOnMe()
    {
            Hello world = new Hello();
            world.UnderHello // after creating an instance, then UnderHello should now be seen by auto-complete
    }
}

If UnderHello was a static class, it would make sense since I can reach static members of a class by directly from Class itself rather than creating instance of the outer class. But it is inner-class.

I am confused.

Can somebody help me now?

Thanks.

  • 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-18T11:23:03+00:00Added an answer on May 18, 2026 at 11:23 am

    Hello.UnderHello is correct, because that is the name of the class.

    This does not mean, however, that you can actually create instances of this inner class without an instance of the outer class.

     Hello.UnderHello x = new Hello.UnderHello(); // this will not work 
                       // at least not from everywhere 
    

    If UnderHello was a static class, it would make sense since I can reach static members of a class by directly from Class itself rather than creating instance of the outer class.

    The class definition itself is always static, if you will. You do not need an instance to refer to it (and the class definition also does not change with the outer instance).

    If UnderHello was a field or a method, then yes, you would need an instance to access it, unless it was declared static.

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

Sidebar

Related Questions

This is pretty simple, I come from a swing/awt background. I'm just wondering what
Just wondering if someone can assist me with the following issue. I have come
I'm wondering if anyone has come across any libraries in javascript that can emulate
I've been wondering this for a while but since it hasn't come up much
Wondering if anyone has gotten the infamous database is locked error from Trac and
Wondering if anyone can help me with this annoying but trivial (in terms of
Folks, we all know that IP blacklisting doesn't work - spammers can come in
From my related question here at SO I've come up with the following PHP
Wondering if anyone has written or come across a good way to log to
I've come up with several manual ways of doing this, but i keep wondering

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.