O'Reilly logo
  • Aadil Hussain thinks this is interesting:

The preceding code won’t compile because the method setWeight doesn’t return a value. Its return type is void. Because the method setWeight doesn’t return a value, there’s nothing to be assigned to the variable newWeight, so the code fails to compile.

From

Cover of OCA Java SE 8 Programmer I Certification Guide

Note

important doubt clearing