public class Account { int a; int b; //using the same name for class variables and parameters can cause issue without using 'this' keyword public void setData(int a ,int b){ this.a = a; this.b = b; } // use different parameter names doesn't has this issue /*public void setData(int c ,int d){ a = c; b = d; }*/ public void showData(){ System.out.println("Value of A ="+a); System.out.println("Value of B ="+b); } public static void main(String args[]){ Account obj = new Account(); obj.setData(2,3); obj.showData(); } }