我試圖創建一個簡單的矩形,它將初始化值x = 10,y = 15,寬度= 35和高度= 50,但它給了我一個錯誤:Java不會導入java.awt.Rectangle
"The import java.awt.Rectangle conflicts with a type defined in the same file"
我該如何解決這個問題?
這裏是我的代碼:
import java.awt.Rectangle;
public class Rectangle
{
public static void main(String[] args)
{
Rectangle myRect = new Rectangle(10, 15, 35, 50);
}
}
我使用Eclipse。
錯誤信息不能更清晰。 – Voicu 2015-02-06 14:38:48
請在此處無意識地發帖之前閱讀錯誤消息*。我知道有時候錯誤信息可能有點神祕,但在這種情況下,它很清楚問題是什麼。如果你仍然無法理解,只需Google即可。 '在同一個文件中定義的類型導入衝突'給我帶來了幾十個確切的問題和解決方案。 – tnw 2015-02-06 14:41:22
我今天開始學習Java .. – Traptor 2015-02-06 14:47:04