I have the below code which creates an object array and then tries to add an object of the same type.
我有下面的代码,它创建一个对象数组,然后尝试添加相同类型的对象。
I get the error "Syntax error, insert "new ClassType ( )" to complete Expression" on the line
我在行上得到错误“语法错误,插入”新的ClassType()“以完成表达式”
vehicles.[index] = nextVehicle;
But it seems to me that there's no problem with it. Is the cast from long to int causing some problem?
但在我看来,它没有任何问题。从长到int的演员阵容是否会导致一些问题?
long vehicleSize = getVehicleSize();
Vehicle[] vehicles= new Vehicle[(int)vehicleSize];
Vehicle nextVehicle = null;
int offSet = 0;
int index= 0;
while (offSet < vehicleSize) {
nextVeh = new Vehicle(db, offSet);
vehicles.[index] = nextVehicle;
index++;
offSet += nextVehicle.getSize();
}
1 个解决方案
#1
7
vehicles.[index] = nextVehicle;
should be
应该
vehicles[index] = nextVehicle;
and
和
nextVeh = new Vehicle(db, offSet);
should probably be
应该是
nextVehicle = new Vehicle(db, offSet);
#1
7
vehicles.[index] = nextVehicle;
should be
应该
vehicles[index] = nextVehicle;
and
和
nextVeh = new Vehicle(db, offSet);
should probably be
应该是
nextVehicle = new Vehicle(db, offSet);