In my Java 8 code,
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(){
You'll notice that
String token = loginResults.entrySet().iterator().next().getValue();
throws a compile error,
Lambda expression's local variable token cannot redeclare another local variable defined in an enclosing scope.
My question is, How would one go about fixing this? I'm pretty new to Java, I should probably know how to fix this, but i don't.
final AtomicReference<Object> token = new AtomicReference<Object>();You have two variable with the same name (token). This is said in the message local variable token cannot redeclare another local variable defined in an enclosing scope.