In main method which should I use?
CarOwner owner = new CarOwner("Danni", "123456789");
CarOwner owner = new CarOwner(); owner.setName("Danni"); owner.setPhoneNumber("123456789");
I know how to make both work, I can edit the class file to suit whichever way it is written in the main method. But what do people do in real life?
Can someone confirm if these are fact or myth?
- to set an inital value of a class property you use a constructor
- you use setter methods instead of using constructors
- you use the setter methods to 'modify' a property
- using a constructor or setter method to set a property depends on whether the property value is likely to change