gpt4 book ai didi

java - 内部类不能有静态声明 - public static final String[]

转载 作者:搜寻专家 更新时间:2023-11-01 09:26:10 24 4
gpt4 key购买 nike

我在第 5 行有问题

public static final String[] CREATIVE_SDK_SCOPES = { "email", "profile", "address"};

Inner classes cannot have static declarations

 public final class Keys {
public static final String CREATIVE_SDK_CLIENT_ID = "xxxxxxxx";
public static final String CREATIVE_SDK_CLIENT_SECRET = "xxxxxxxxx";
public static final String CREATIVE_SDK_REDIRECT_URI = "xxxxxxxxxx";
public static final String[] CREATIVE_SDK_SCOPES = { "email", "profile", "address" };
}
private static final String CREATIVE_SDK_CLIENT_ID = Keys.CREATIVE_SDK_CLIENT_ID;
private static final String CREATIVE_SDK_CLIENT_SECRET = Keys.CREATIVE_SDK_CLIENT_SECRET;
private static final String CREATIVE_SDK_REDIRECT_URI = Keys.CREATIVE_SDK_REDIRECT_URI;
private static final String[] CREATIVE_SDK_SCOPES = Keys.CREATIVE_SDK_SCOPES;

inner classes cannot have static declarations

你能解释一下这是什么意思以及如何解决吗?

最佳答案

because an inner class is associated with an instance, it cannot define any static members itself.

https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

您必须改用静态嵌套类。

public static final class Keys {

参见 Why can't inner classes declare static members?

关于java - 内部类不能有静态声明 - public static final String[],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50441042/

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