Reputation: 1215
I have the following code
set1.forEach( k -> {
for (String s : set2) {
if(s.split(";")[0].equals(k){
//do something
}
}
...
but I have this error
k cannot be resolved to a variable
Is there a way to read this variable?
Thanks
Upvotes: 0
Views: 73
Reputation: 479
You missed one paranthesis after k. You should have two closed paranthesis as below near equals
Set<String> set1 = new HashSet<>();
Set<String> set2 = new HashSet<>();
set1.forEach((k)-> {
for (String string : set2) {
if(string.split(":")[0].equals(k)){
//do something
}
}
});
Upvotes: 2