In simple terms: Use constructor if you think initialization is mandatory before you can use the object . Use setter method when initialization of variable is non-mandatory to use the object.
In simple terms: Use constructor if you think initialization is mandatory before you can use the object . Use setter method when initialization of variable is non-mandatory to use the object.