introduce variable inside lambda: do not step out of lambda block

This commit is contained in:
anna
2013-11-29 21:12:28 +01:00
parent 2fdb93a278
commit 2b49ac9eb4
5 changed files with 52 additions and 2 deletions
@@ -0,0 +1,20 @@
import java.util.ArrayList;
import java.util.Collection;
public class ExtractVariableSample {
interface I {
void foo(String s);
}
public static void main(String[] args) {
Collection<String> strings = new ArrayList<>();
I i = (s) -> { System.out.println(<selection>s.hashCode()</selection>); };
for (String s : strings) {
System.out.println(s.hashCode());
}
}
}