Java Lambda表达式错误
在我的Java 8代码中Java Lambda表达式错误,java,lambda,Java,Lambda,在我的Java 8代码中 public ChangePersonsName(String email, final String password, final String wantedUsername, final String uuid, final long time, int latency, int[] requests, int[] proxyRequests) throws IOException { final AtomicReference<Object>
public ChangePersonsName(String email, final String password, final String wantedUsername, final String uuid, final long time, int latency, int[] requests, int[] proxyRequests) throws IOException {
final AtomicReference<Object> token = new AtomicReference<Object>();
final AtomicReference<ArrayList<?>> newHeaders = new AtomicReference<ArrayList<?>>();
new Thread(() -> {
boolean lock = true;
while (lock) {
if (time - System.currentTimeMillis() > 60000) continue;
Map<Header[], String> loginResults = null;
try {
loginResults = this.login(email, password, uuid);
}
catch (IOException e) {
e.printStackTrace();
}
String token = loginResults.entrySet().iterator().next().getValue();
Header[] headers = loginResults.entrySet().iterator().next().getKey();
newHeaders.set(new ArrayList<Object>());
for (Header header : headers) {
if (!header.toString().startsWith("Set-Cookie:")) continue;
((List<BasicHeader>)newHeaders.get()).add(new BasicHeader("Cookie", header.toString().split("Set-Cookie: ")[1]));
}
lock = false;
}
}
).start();
new Timer().schedule(new TimerTask(){
抛出编译错误
Lambda表达式的局部变量标记无法重新声明在封闭范围中定义的另一个局部变量
我的问题是,如何着手解决这个问题?我对Java非常陌生,我应该知道如何解决这个问题,但我不知道 此范围中已存在名为
标记的变量。你已经在第二排申报了。要修复此问题,只需重命名第二个变量:
String newToken = loginResults.entrySet().iterator().next().getValue();
此范围中已存在名为标记的变量。你已经在第二排申报了。要修复此问题,只需重命名第二个变量:
String newToken = loginResults.entrySet().iterator().next().getValue();
final-AtomicReference令牌=新的AtomicReference()
您有两个同名的变量(token
)。这是在消息中说的,局部变量标记不能重新声明在封闭范围中定义的另一个局部变量。“如何解决此问题?”请将其命名为其他名称。final AtomicReference token=new AtomicReference()
您有两个同名的变量(token
)。消息中说,局部变量标记无法重新声明在封闭范围中定义的另一个局部变量。“如何解决此问题?”请将其命名为其他名称。可能重复的