Skip to content

Commit e0a928d

Browse files
committed
added foreach demo
1 parent 5a66215 commit e0a928d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package java8.functionalInterface;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class ForEachDemo3
7+
{
8+
public static void main(String[] args)
9+
{
10+
List<Integer> intItems = new ArrayList<>();
11+
intItems.add(10);
12+
intItems.add(50);
13+
intItems.add(40);
14+
intItems.add(30);
15+
intItems.add(20);
16+
17+
//lambda
18+
intItems.forEach(item->{
19+
if(item>20)
20+
{
21+
System.out.println(item);//50 40 30
22+
}
23+
});
24+
}
25+
}

0 commit comments

Comments
 (0)