Ok, so Eclipse allows me to fix this the issue in line 6 of TestGetSet by creating a field setX in type GetSet, but I know this is the wrong course of action. Can anyone please help me out?
public class TestGetSet { public static void main(String[] args) { GetSet obj1 = new GetSet(); obj1.setX =(21); System.out.print(obj1.getX()); } }
public class GetSet { public int x = 22; // public int setX; public GetSet() { System.out.println("x = " + x); } public int getX() { return x; } public void setX(int x) { this.x = x; } }