Created
September 9, 2020 15:43
-
-
Save javabuddy/f9e566720a4a3e1fccc6b3bede5e65e4 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
import java.util.Arrays; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
/** | |
* Program to demonstrate coding for interfaces in Java | |
* @author WINDOWS 8 | |
* | |
*/ | |
public class Hello { | |
public static void main(String args[]) { | |
// Using interface as variable types | |
List<String> rawMessage = Arrays.asList("one", "two", "three"); | |
List<String> allcaps = toCapitalCase(rawMessage); | |
System.out.println(allcaps); | |
} | |
/** | |
* Using Interface as type of argument and return type | |
*/ | |
public static List<String> toCapitalCase(List<String> messages) { | |
return messages.stream() | |
.map(String::toUpperCase) | |
.collect(Collectors.toList()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment