Java 8 forEach example

In this article will discuss about Java 8 forEach concept, Check out simple example below

 

  Map<String, Integer> items = new HashMap<>();  items.put("A", 1);  items.put("B", 2);  items.put("C", 3);  items.put("D", 4);  items.put("E", 5);  items.put("F", 6);    for (Map.Entry<String, Integer> entry : items.entrySet()) {  	System.out.println("Item : " + entry.getKey() + " Count : " + entry.getValue());  }

 

SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment