in the code above, line 16 don't compile because if a method doesn't return a value, we can't assign the result of that method to a variable. But setWeight method
is also void and line 3 compiles without any errors. i can't understant why line 16 doesn't compile while line 3 compiles succesfully
As you code stands right now you have one issue copied twice
In order to get the value of weight you would need to use a method name "getWeight" or something like that. With this new method you can return the value of the weight variable.
void can/should be thought of a nothing. On line 13 you are trying to give a value of nothing (void) to the newWeight variable which you told the system would always be a double.
Usually when staring out with a project your get methods (getters) and set methods (setters) will be only a few lines of code.
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
posted 2 years ago
thanks for your response
Everybody's invited. Even this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop