0
我目前正在编写一个代码,它从文件中获取信息,然后使用基于对象Request
(我已经在另一个java文件中编写)填充数组信息在文件中。这是我在我的main
方法使用参数化构造函数添加到ArrayList
Scanner userIn = new Scanner(System.in);
System.out.println("Please input the file name that you would like to be read into reqMover");
String thisFile = userIn.next();
FileReader inReader = new FileReader(thisFile);
Scanner inFile = new Scanner(inReader);
ArrayList<Request> newReq = new ArrayList<Request>();
do{
newReq.add(Request(inFile.nextInt(), inFile.nextInt(),
inFile.nextInt(), inFile.nextInt()));
inFile.nextLine();
}while(inFile.hasNextLine());
此代码驻留在被称为reqMover
一个java文件至今。我遇到的这个问题是,编译器告诉我“方法Request(int, int, int, int)
对于类型reqMover
未定义”,尽管该方法是我在其他类中创建的构造函数。使用这个构造函数加载ArrayList
有什么特别的需要吗?
你需要使用“特殊”的关键字的签名:'新的请求(...)'。 –