Last active
September 2, 2015 14:17
-
-
Save goyuninfo/95138cfc449b4c913d04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @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