gpt4 book ai didi

java枚举传递数组作为构造的第二个参数

转载 作者:行者123 更新时间:2023-12-01 18:05:55 25 4
gpt4 key购买 nike

简单

public enum AvailableTestServices {
UserContext("userContext", ["userURI"]), Level0and1ForUser("level0and1ForUser", ["userURI"]);
private String serviceName;
private String[] requiredParameters;

private AvailableTestServices(String serviceName,
String[] requriedParameters) {
this.serviceName = serviceName;
this.requiredParameters = requriedParameters;
}

public String getValue() {
return serviceName;
}
public String[] getRequiredParameters(){
return this.requiredParameters;
}
}

我在以下位置的 , 上遇到异常:

UserContext("userContext", ["userURI"]), Level0and1ForUser("level0and1ForUser", ["userURI"]);

错误是:

Syntax error on token ",", Expression expected after this token AvailableTestServices.java /

enter image description here

最佳答案

正确的方法应该如下:

UserContext("userContext", new String[]{"userURI"}),
Level0and1ForUser("level0and1ForUser", new String[]{"userURI"});

关于java枚举传递数组作为构造的第二个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36429055/

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