我正在尝试为 ParkingArea(string, int, int, int, int) 创建一个数组。正在扫描的文件在这里http://uwf.edu/jcoffey/data.txt
try
{
Scanner scan = new Scanner(file);
for (int i = 0;scan.hasNext(); i++)
{
for(int x = 0; x < 4; x++)
{
if(x == 0)
{
name = scan.next();
}
else
{
array[x-1] = scan.next();
}
}
ParkingArea[i] = new ParkingArea(name, array[0], array[1], array[2], array[3]);
}
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
编译时出现此错误。
Parking.java:40: error: incompatible types
array[x-1] = scan.next();
^
任何帮助将不胜感激。