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");
}
The compiler will give you an error if your class is inner class and is not static, e.g.:
This will work if the inner class is static:
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.