public class DB
// ineffective method to calculate dB:
public static void toDecibell(double x)
{
x = 10.0 * Math.log10(x); // change formal parameter value
}
};
.......
power = 100.0; // 100 Watts.
DB.toDecibell(power); // conversion to dBW fails. power == 100 after call
public void copyNameTo(Greeter other)
{
other.name = this.name;
}
......
Greeter worldGreeter = new Greeter("World");
Greeter daveGreeter = new Greeter("Dave");
worldGreeter.copyNameTo(daveGreeter);