我做的一個類和某些原因「無法找到符號」爲錯誤無法找到符號
perimeter = width + length;
return perimeter;
我不知道爲什麼這裏會出現一個錯誤的錯誤(或者是否有別的東西錯了我的代碼,我只是在學校裏開始了Java的,因此任何提示將是有益的。
/**
* A rectangle has a length and a width. Its perimeter can be calculated.
*/
public class Rectangle
{
private int length;
private int width;
/**
* Constructs a rectangle with a specified length and width
* @param len the length of the rectangle
* @param wid the width of the rectangle
*/
public Rectangle(int len, int wid)
{
length = 0;
width = 0;
}
/**
* Sets the length and width of the rectangle
* @param len the new length
* @param wid the new width
*/
public void setDimensions(int len, int wid)
{
length = len;
width = wid;
}
/**
* Returns the perimeter of the rectangle
* @return the perimeter of the rectangle
*/
public int calculatePerimeter()
{
perimeter = width + length;
return perimeter;
}
'parameter'從未定義? – Li357