Skip to content

Conversation

@BobHanson
Copy link
Collaborator

Java 8 function interfaces, method reference, and streams

hansonr and others added 13 commits July 14, 2018 12:09
 the "::" operator
 lambda expressions
 java.util.function.*
 java.util.stream.*
 default methods in interfaces
 the "::" operator
 lambda expressions
 java.util.function.*
 java.util.stream.*
 default methods in interfaces
 the "::" operator
 lambda expressions
 java.util.function.*
 java.util.stream.*
 default methods in interfaces
working:

	// http://www.javainuse.com/java/java8_method_References
		List<String> myList = Arrays.asList("b1", "a2", "a1", "c2", "c1");
		System.out.println("\n\n------- stream().map().forEach() using lambda
expressions -------");
		myList.stream().map(s -> s.toUpperCase()).forEach(s ->
System.out.print(s + " "));

		System.out.println("\n\n------- stream().map().sorted().forEach()
using Class::method method reference --------");
		myList.stream().map(String::toUpperCase).sorted().forEach(System.out::print);

		// https://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/

		System.out.println("\n\n-------
stream().filter().map().sorted().forEach() --------");
		myList.stream()
			.filter(s -> s.startsWith("c"))
			.map(String::toUpperCase)
			.sorted()
			.forEach(System.out::print);
		System.out.println("\n");
@BobHanson BobHanson merged commit 4c08840 into java2script:master Jul 20, 2018
BobHanson added a commit that referenced this pull request Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant