Change your code to:
public class ThingHolderTester {
public static void main(String[] args) {
ThingHolder t = new ThingHolder();
t.setThing("First Object");
System.out.println("The thing is currently " + t.getThing() + " and the ThingHolder has been updated " + t.getUpdateCounter() + " times");
t.setThing("Second Object");
System.out.println("The thing is currently " + t.getThing() + " and the ThingHolder has been updated " + t.getUpdateCounter() + "times");
}
Problems:
- To call a function you need to add "()" and add required arguments within.
- The setThing method updates the counter itself, no need to do it in main code manually.
- The updateCounter property is private and cannot be accessed directly by other class.