Your definition is correct, but in the example above, there is some cause to be hesitate, Actually your will be more clear if you kindly distribute the variable as member variable and the instance, other pattern will be classified based on variable scope known as local and global variable. On your example you have commented int x and y as instance, but actually they doesn't , they are member variable with the private visibility mode, but the actual instance on your code is point p(at class main) where the class point has instantiated by the new operator(new is a reserved key word in java, some others are abstract, boolean, break, byte, char, cast, const, continue, default, do, double, jump, goto, finally, through, try, catch, private, protected, public, static, void etc in a count of 87, when i was studied)
sorry if the post hurts ! But my opinion is to study hard to learn at one time, never repeat it for the clear concept. it will pull you to the bound but time will never wait
If i am in a wrong way please refer me the book name so, i can be cleared!
In a class member with private modifier can be access by public method so that other class can access. Here her example is i think ok but not details. Both static and without static variables are global member within a class. But uses is different.
To use class variable you don't need to create class instance. here in example coordinate with public modifier
You cannot access x and y members even though if set as public modifier without creating class instance
If you use private visibility mode, i may guarantee you that u can't access this method or variable from the outside of that class
yea, exactly, i have found your msg but a little bit later
scope of the local variable is in the method body or in the method parameters.
We access all private members by public methods of that class. Other classes does not allows to access private member directly.
Here "p" is the class instance or class object of Point class created by new keyword in Main class.
Comments 12