 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
001 Guest
|
Posted: Thu Mar 29, 2007 12:48 am Post subject: Little problem with class-variable acces |
|
|
I have a class with a static variable in it and now I want it to be accessed
from within a static method, but that method has an argument with the same
name. When referring to an object there is the 'this' keyword, but what to
do when you refer to the class itself?! |
|
| Back to top |
|
 |
Lew Guest
|
Posted: Thu Mar 29, 2007 7:10 am Post subject: Re: Little problem with class-variable acces |
|
|
001 wrote:
| Quote: | I have a class with a static variable in it and now I want it to be accessed
from within a static method, but that method has an argument with the same
name. When referring to an object there is the 'this' keyword, but what to
do when you refer to the class itself?!
|
(Also was posted to clj.programmer as "Little problem with class-variable acces")
Please do not multi-post; it fragments the threads and makes it at least
difficult for folks to follow along. It also risks wasting people's time who
may not realize that the same answer is being provided elsewhere.
Instead, if you really truly must reach multiple newsgroups, cross-post with a
follow-up set to the one group where the thread should continue.
-- Lew |
|
| Back to top |
|
 |
Barney Guest
|
Posted: Sat Apr 07, 2007 6:17 pm Post subject: Re: Little problem with class-variable acces |
|
|
On Wed, 28 Mar 2007 21:48:26 +0200, 001 wrote:
| Quote: | I have a class with a static variable in it and now I want it to be accessed
from within a static method, but that method has an argument with the same
name. When referring to an object there is the 'this' keyword, but what to
do when you refer to the class itself?!
|
Just use the name of the class, a dot, and the name of the variable. E.g.
if your class is called Teapot you can do something like:
Teapot.volume=42;
Or you could change the name of the method argument. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|