gpt4 book ai didi

Java找不到构造函数

转载 作者:行者123 更新时间:2023-11-29 05:08:53 25 4
gpt4 key购买 nike

我觉得我以错误的方式处理这段代码。本质上,我试图从文本文件加载客户端信息。我的麻烦代码看起来像这样......

//load clients data from file
file = new File(clientsOutputFile);
sc = new Scanner(file);
Client client;
String givenName, familyName;
String industry, projectName;
// iterate for each line in venues file, one by one
while(sc.hasNextLine()) {
str = sc.nextLine();
// split line by tab
parts = str.split("\t");
// check if all details of client are provided
if(parts.length == 5) {
phone = Integer.parseInt(parts[0]);
givenName = parts[1];
familyName = parts[2];
industry = parts[3];
projectName = parts[4];
client = new Client(phone, givenName, familyName, industry, projectName);
// add client to client's model
clientMdl.addElement(client);
}
}
sc.close();

我在编译时收到的错误是...

    Error: /Users/Desktop/Migration/BookingGUI.java:647: cannot find
symbol
symbol : constructor Client(int,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
location: class Client

非常感谢任何帮助。

最佳答案

您需要添加一个具有参数的构造函数。 Java 会设置一个默认值,但我一直觉得它不可靠。

关于Java找不到构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29423860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com