+ 2
Diff between 'set' and constructor
if constructors are used for providing the initial values for the attributes of objects what is the difference between the "set" and "constructor"?
1 Antwort
+ 14
The constructor allows you to set the attributes when you create the object. Ex:
ID user = new ID("User", 12387); //Assigns username and idNumber
Setters allow you to change an object's attributes whenever you want. Ex:
user.setName(Scanner.nextLine());