我编码在Java中的一个项目,并创建了一个类用下面的代码:如何创建现有类的新实例?
public class VehInfo {
private int[][] traffic = new int[20][150];
private int mintime = 0;
private int numvehicles = 1;
private int[] vehiclecode = new int[5];
public VehInfo(int[][] traffic, int mintime, int numvehicles, int[] vehiclecode) {
this.traffic = traffic;
this.mintime = mintime;
this.numvehicles = numvehicles;
this.vehiclecode = vehiclecode;
}
}
我想用下面的代码
VehInfo vehinfo = new VehInfo(new int[20][150], new int, new int, new int[5]);
创建这个类的一个新实例。然而, Netbeans的通知我:
必需的:(INT [] [],INT,INT,INT [])
发现:(int [] [],int [],int [],int [])
我在想什么?我显然不会将这些变量初始化为int [],那么为什么它们会被拾取?
你认为那是新的INT'将完成? – Gimby
新的int应该被int替换掉 – user1121883
通过哪个int? “new int”的价值是什么? – Kayaman