Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为文件声明对象数组时出现标识符错误_Java_Arrays - Fatal编程技术网

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