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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:27:26+00:00 2026-06-17T04:27:26+00:00

Why I must pass parameter to static Method with private access control in Java.

  • 0

Why I must pass parameter to static Method with private access control in Java.

class Test extends Teacher
{
  int field = 123;

  private static void accessInstance(Test test)
  {
    System.out.println(test);
  }
}

For the below code it generates error

  private static void accessInstance()
  {
     System.out.println("Hi there");
  }
  • 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-06-17T04:27:27+00:00Added an answer on June 17, 2026 at 4:27 am

    The compiler will give you an error if your class is inner class and is not static, e.g.:

    class X
    {
        class Test
        {
            int field = 123;
    
            private static void accessInstance(Test test)
            {
                System.out.println(test);
            }
        }
    }
    

    This will work if the inner class is static:

     class X
    {
        static class Test
        {
            int field = 123;
    
            private static void accessInstance(Test test)
            {
                System.out.println(test);
            }
        }
    }
    

    You should correct your post I think.

    A static inner class means you can instantiate it without having an instance of an enclosing outer class instance.

    JLS 8.1.3. Inner Classes and Enclosing Instances

    Inner classes may not declare static members, unless they are constant
    variables (§4.12.4), or a compile-time error occurs.

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

Sidebar

Related Questions

I saw a method called Control.FromHandle which (should) give you the access to it.
Slightly possible duplicate : Instance method vs. static method with ref parameter If I
I have a parameter which I must pass as part of a url. The
I am getting a error: OmniAuth::Strategies::Facebook::NoAuthorizationCodeError (must pass either a `code` parameter or a
When i am creating SPFields the constructor states that you must pass in a
If a process with unicode enabled creates a named pipe, it must pass a
I want to pass heap-allocated objects from a dll. Obviously, memory must be managed
Must be a way looping through this code: private void loadSprites() { this.sprites[0] =
I'm building my own framework, and I'm trying to pass a parameter to a
I've got a method I wish to pass an SqlExpression and connection string to

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.