Skip to content

Instantly share code, notes, and snippets.

@javabuddy
Created September 9, 2020 15:43
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 javabuddy/f9e566720a4a3e1fccc6b3bede5e65e4 to your computer and use it in GitHub Desktop.
Save javabuddy/f9e566720a4a3e1fccc6b3bede5e65e4 to your computer and use it in GitHub Desktop.
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