public void test(){
String x;
List<String> list=Arrays.asList("a","b","c","d");
list.forEach(n->{
if(n.equals("d"))
x="match the value";
});
}
1.Like the code above, I want to set the value of a variable beside the foreach block, can it works?
2.And why?
3.And the foreach iterator is in order or disorder?
4.I think the lamdas foreach block is cool and simple for iterator,but this is really a complicated thing to do rather than the same work in java 7 or before.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…