JiafanZhou
版主
发贴: 736
积分: 61
|
于 2008-11-11 22:17
gbluo wrote: 还有别的方法吗?
No! It is the only mean to get access to the non-static member field. The reason for this is that non static member fields or methods are bounded to a specific instance of the object. Thus it will be forced to be manipulated by the instance reference.
Another thing worth to be mentioned is that it is *not* recommended to declare public to member fields. It would be preferred to declare public get/set methods, in conformance with the JavaBean standard. And it is subject to one of the most important OO rule: Encapsulation.
By the way, why do you declare your class name as "SHXT"? It is a forbidden keyword in the Java World....
Regards, Jiafan
When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me.
|