Very often I see in Java code a constructor been used instead of void setColor() method for example.
Why would somebody do this?
So why doing this:
public class Dog { String color; public Dog(String color) { this.color = color; } }
Instead of:
public class Dog { String color; public void setColor(String color) { this.color = color; } }