你的程序有某個臨時變量被賦值超過一次,它既不是循環變量,也不是一個集用臨時變量(collection temporary variable)。
針對每次賦值,創造一個獨立的、對應的臨時變量。
double temp = 2 * (_height + _widgth);
System.out.println(temp);
temp = _height * _widgth;
System.out.println(temp);
| |
\ /
final double perimeter = 2 * (_height + _widgth);
System.out.println(perimeter);
final double area = _height * _widgth;
System.out.println(area);