Skip to content

Commit 2c5acae

Browse files
committed
added foreach4.java
1 parent e0a928d commit 2c5acae

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package java8.functionalInterface;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class ForEachDemo4
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+
// method reference
18+
intItems.forEach(System.out::println); // 10 50 40 30 20
19+
20+
}
21+
}

0 commit comments

Comments
 (0)