V
Vikram Kalra
Hi All
I am new to this group and to java too.
I have a question regarding variable name hiding for static variables
in a static context. Here is the sample code:
class RangeClass{
static int i;
public static void main(String args[]){
setI(10);
int i = getI();
System.out.println(i);
}
static void setI(int i){
this.i = i;
}
static int getI(){
return i;
}
}
In the code above, you can see method setI, which takes an integer
with name 'i' as an arguement which is same as the name of the static
variable declared in the class.
Now can anyone tell me how can i refer to the static variable 'i' in
method setI keeping the same name of the arguement?
Regards
Vikram
I am new to this group and to java too.
I have a question regarding variable name hiding for static variables
in a static context. Here is the sample code:
class RangeClass{
static int i;
public static void main(String args[]){
setI(10);
int i = getI();
System.out.println(i);
}
static void setI(int i){
this.i = i;
}
static int getI(){
return i;
}
}
In the code above, you can see method setI, which takes an integer
with name 'i' as an arguement which is same as the name of the static
variable declared in the class.
Now can anyone tell me how can i refer to the static variable 'i' in
method setI keeping the same name of the arguement?
Regards
Vikram