AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Little problem with class-variable acces

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Discussions
View previous topic :: View next topic  
Author Message
001
Guest





PostPosted: Thu Mar 29, 2007 12:48 am    Post subject: Little problem with class-variable acces Reply with 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?!
Back to top
Lew
Guest





PostPosted: Thu Mar 29, 2007 7:10 am    Post subject: Re: Little problem with class-variable acces Reply with quote



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





PostPosted: Sat Apr 07, 2007 6:17 pm    Post subject: Re: Little problem with class-variable acces Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Discussions All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.