I have very very basic java question:
For the class below:
public class Hello {
public final static int a;
public final int a;
public int a;
int a;
static public void Method(){}
public void Method(){}
private void Method(){}
}
what is the difference between the declartion and Method above above??
This declares a constant property that is static. That means it is not tied to any instance of the Hello class and is accessible both outside the Hello class and inside. Since it is final you will not be able to modify this value and it will always be its default value of 0.
Similar to the one above, except it is tied to this instance of Hello.
This is a public property of this instance of Hello, modifiable both inside and outside the Hello class. This is considered bad practice.
A default level property of this instance of Hello. Modifiable only inside this instance of Hello.
A static (not tied to an instance) method within Hello class that is accessible both internally and externally. It does not have access to things like:
It cannot access these because this method is not tied to this instance where as all of those values are.
A public method of Hello class. It is accessible both internally and externally.
Similar to the method above, except it is only accessible internally.