一个二传手使用“ this”,一个不使用“ this”,但是它们的功能相同吗?
public void setHoursWorked(int hours) {
if (hours > 0)
hoursWorked = hours;
else {
System.out.println("Error: HoursWorked Cannot be Smaller than Zero");
System.out.println("Error: HoursWorked is not updated");
}
}
public void setHoursWorked (int hoursWorked) {
if (hoursWorked > 0) {
this.hoursWorked = hoursWorked
}
}