» Java开发网 » Java SE 综合讨论区
打印话题 寄给朋友 订阅主题
于 2008-11-11 22:17
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....
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.
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent |
Copyright © 2002-2020 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号
客服电话 0592-8750026 客服信箱 email@example.com 客服QQ 714923