gpt4 book ai didi

java - 错误: “; Expected Not a statement ”

转载 作者:行者123 更新时间:2023-12-01 23:00:20 26 4
gpt4 key购买 nike

对于行 data[] = {nam, addres, adminStaf,phoneNumbe,typ}; NetBeans 给了我这个错误

"; Expected Not a statement" 

我不知道为什么这不起作用,我们将不胜感激。

public Object[] getObjects() {

Object[] data = {};

for (int i = 0; i < Storage.getAgencies().size(); i++)
{
String nam = Storage.getAgencies().get(i).getName();
String addres = Storage.getAgencies().get(i).getAddress();
String adminStaf = Storage.getAgencies().get(i).getAdminstaff();
String phoneNumbe = Storage.getAgencies().get(i).getPhonenumber();
String typ = Storage.getAgencies().get(i).getType();

data[] = {nam, addres, adminStaf, phoneNumbe, typ};
}
return data;
}

最佳答案

您使用的语法仅在初始化数组时才允许。您应该执行以下操作:

data = new String[] {nam, addres, adminStaf, phoneNumbe, typ};

关于java - 错误: “; Expected Not a statement ” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23457366/

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