Skip to content

Instantly share code, notes, and snippets.

@goyuninfo
Last active September 2, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goyuninfo/95138cfc449b4c913d04 to your computer and use it in GitHub Desktop.
Save goyuninfo/95138cfc449b4c913d04 to your computer and use it in GitHub Desktop.
/**
*
* @author i88.ca
*/
public class Main {
public static void main(String[] args) {
String[] atp = {"Johon Doe", "Peter Smith", "Bruce Lee", "Jacky Chen"};
List<String> contacts = Arrays.asList(atp);
// Old looping
for (String contact : contacts) {
System.out.print(contact + "; ");
}
System.out.println();
// Using lambda expression and functional operations
contacts.forEach((contact) -> System.out.print(contact + "; "));
System.out.println();
// Using double colon operator in Java 8
contacts.forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment