
class Test{ int x; Test(int x){ this.x=x; } static void access(){ System.out.println("x= "+x); }} class Static{ public static void main(String ar[]){ Test obj=new Test(55); Test.access();
} }

Hi,
We have modified your code.
class Test{
static int x;
Test(int x){
this.x=x;
}
static void access(){
System.out.println("x= "+x);
}
}
class Static{
public static void main(String ar[]){
Test obj=new Test(55);
obj.access();
}
}
In the above code, this operator invokes the constructor of the same class and will allow you to change the value. If the method is static then the field it used, should be static.In the main method, an integer value is defined in the constructor of Test class and its object called the method access().
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.