Java 为文件声明对象数组时出现标识符错误
我收到一个Java 为文件声明对象数组时出现标识符错误,java,arrays,Java,Arrays,我收到一个预期错误。括号内输入字符串处的信号 有什么建议吗?您应该为参数指定一种类型。试试这个: public static Vehicle[] fillArray(inputString) throws exception { while(readRecords.ready()) { Vehicle newVehicle; checkType = readRecords.readLine(); if(checkType.equals("v
预期错误
。括号内输入字符串处的信号
有什么建议吗?您应该为参数指定一种类型。试试这个:
public static Vehicle[] fillArray(inputString) throws exception {
while(readRecords.ready()) {
Vehicle newVehicle;
checkType = readRecords.readLine();
if(checkType.equals("vehicle")) {
String ownersName = readRecords.readLine();
String address = readRecords.readLine();
String phone = readRecords.readLine();
String email = readRecords.readline();
newVehicle = new Vehicle(ownersName,address,phone,email);
list.add(newVehicle);
}
您需要说明参数的类型:
public static Vehicle[] fillArray(String inputString) throws exception
否则,编译器不知道
inputString
是字符串、int还是其他对象。它不会猜名字。你能告诉我们所有这些的代码吗<代码>异常应大写。标识符预期错误每个输入参数必须有一个类型。在()
s中的输入字符串
之前输入一个类型。@Rickie我知道。我需要查看导致错误的代码,因为我显然不是通灵者。2件事,inputString
必须通过声明其数据类型来支持,并且如果您使用Java的exception
public static Vehicle[] fillArray(String inputString) throws Exception