Guest User

Untitled

a guest
Aug 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. package com.techpredators.functionalinterfaces;
  2.  
  3. import java.util.Date;
  4. import java.util.function.Supplier;
  5.  
  6. public class SupplierInterfaceTest {
  7. public static void main(String args[]) {
  8.  
  9. Supplier<String> stringSupplier = () -> new String("I am String");
  10. System.out.println("String in stringSupplier is ::" + stringSupplier.get() + "::");
  11.  
  12. // Constructor
  13. Supplier<String> stringEmpty = String::new;
  14. System.out.println("EmptyStr is::" + stringEmpty.get() + "::");
  15.  
  16. // Custom method
  17. Supplier<Date> date = SupplierInterfaceTest::returnSystemDate;
  18. Date systemDate = date.get();
  19. System.out.println("systemDate::" + systemDate);
  20. }
  21.  
  22. public static Date returnSystemDate() {
  23. return new Date();
  24. }
  25. }
Add Comment
Please, Sign In to add comment