我新的Java和我已經從維基教科書下載的PDF文檔,並試圖運行一個程序我收到以下錯誤:獲取在Java錯誤而編譯或運行
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Distance.main(Distance.java:7)
這是代碼我試圖運行:
public class Distance
{
private java.awt.Point point0, point1;
public Distance(int x0, int y0, int x1, int y1)
{
point0 = new java.awt.Point(x0, y0);
point1 = new java.awt.Point(x1, y1);
}
public void printDistance()
{
System.out.println("Distance between " + point0 + " and " + point1
+ " is " + point0.distance(point1));
}
public static void main(String[] args)
{
Distance dist = new Distance(
intValue(args[0]), intValue(args[1]),
intValue(args[2]), intValue(args[3]));
dist.printDistance();
}
private static int intValue(String data)
{
return Integer.parseInt(data);
}
}
什麼是你的輸入和輸出? – carlspring
該程序甚至沒有編譯它只是顯示一個錯誤,這就是它..沒有其他.. –