in this code :
public class Main{
private void method()
{
System.out.println("inside method");
}
public static void main(String[] args) {
Main obj = new Main();
obj.method();
}
}
Why we can access the private method using an object from the class when we are in the class , while we cann't do that outside the class ? (I mean what is the logical reason ?)
Another case is : the main
method is static so why there is no compiler error complaining about "accessing non-static method from a static method "??