Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: New Way to Iterate a List in Java 8

Learn a new way to iterate a list in Java 8.


advertisement

WEBINAR: On-Demand

Unleash Your DevOps Strategy by Synchronizing Application and Database Changes REGISTER >

We can see that the method println is referred by System.out using ::

import java.util.*;

public class NewForEach 
{
   public static void main(String args[])
   {
      List empNames = new ArrayList();
      
      empNames.add("Andrew");
      empNames.add("Mohin");
      empNames.add("Rajan");
      
      empNames.forEach(System.out::println);
   }
}

 

Visit the DevX Tip Bank

 





   
Sridhar M S. is a Java developer from Bangalore, India. He holds a master's degree in Computer Science.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date