posted 7 years ago
Hello Charles, how are you?
I'm looking at the book here, and you are talking about the following constructors given in the book
The explanation is about when, for example, new Hamster(10) is called, this constructor will create an object with default values for its instance variables. So, the weight and the color of the object created by calling the first constructor (the one with one parameter) will be initialized with the default values: for a String, null, and for an int, 0. So, the object created by calling new Hamster(10) will have null for its color, and 0 for its size (because we don't initialize them).
Then, when the book says "It then constructs a different object with the desired weight and color and ignores the new object", it's talking about the other constructor call, new Hamster(weight, "brown");
Inside the first constructor, we are calling another constructor, and this will construct another object, initializing its values with the desired weight and color passed in the constructor call, since we assign those values to the instance variables, as in line 1 and line 2. This new object is created, but it is ignored, since we call new Hamster(weight, "brown") and never assign it to a variable, and never use it.