Little problem with class-variable acces

0

001

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?!
 
D

Daniel Pitts

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?!

class MyClass {
private static int value;
public static void setValue(int value) {
MyClass.value = value;
}
}

Hope this helps,
Daniel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top