Regards,<br />Sourin.
otherwise you will not be able to create an instance of a class from main method using class's constructor since it's also a non static block
[My Blog]
All roads lead to JavaRanch
Regards,<br />Sourin.
Originally posted by Wiyanto Ngasinur:
Need some explanation too
regardless of whether it is the same instance or not
Originally posted by Wiyanto Ngasinur:
hi Henry, thanks for the reply but i still not understand, maybe can you be more verbose ... why private variable court can be accessed thru reference ? since it considered as accessing from outside
Private has nothing to do with whether it is accessed via a reference or not. It is perfectly fine to access a private member from a different object -- as long as this different object is of the same class type. In this case, it is not even being accessed from a different object. It is being access from a static method, of the same class type.
[My Blog]
All roads lead to JavaRanch
Private has nothing to do with whether it is accessed via a reference or not. It is perfectly fine to access a private member from a different object -- as long as this different object is of the same class type. In this case, it is not even being accessed from a different object. It is being access from a static method, of the same class type.
[My Blog]
All roads lead to JavaRanch
Private has nothing to do with whether it is accessed via a reference or not. It is perfectly fine to access a private member from a different object -- as long as this different object is of the same class type. In this case, it is not even being accessed from a different object. It is being access from a static method, of the same class type.
[My Blog]
All roads lead to JavaRanch
Private has nothing to do with whether it is accessed via a reference or not. It is perfectly fine to access a private member from a different object -- as long as this different object is of the same class type. In this case, it is not even being accessed from a different object. It is being access from a static method, of the same class type.
[My Blog]
All roads lead to JavaRanch
Private has nothing to do with whether it is accessed via a reference or not. It is perfectly fine to access a private member from a different object -- as long as this different object is of the same class type. In this case, it is not even being accessed from a different object. It is being access from a static method, of the same class type.
[My Blog]
All roads lead to JavaRanch