Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. interface Lambda{
  2.  
  3. default void dummy(){
  4. System.out.println("Call this..");
  5. }
  6.  
  7. void yummy();
  8. }
  9.  
  10. public class DefaultCheck {
  11.  
  12. public static void main(String[] args) {
  13.  
  14. DefaultCheck check = new DefaultCheck();
  15. check.activate(new Lambda() {
  16.  
  17. @Override
  18. public void yummy() {
  19. dummy();
  20. }
  21. });
  22.  
  23. }
  24.  
  25. void activate(Lambda lambda){
  26. lambda.yummy();
  27. }
  28.  
  29. check.activate(() -> {
  30. dummy();
  31. });
  32.  
  33. check.activate(new Lambda() {
  34. @Override
  35. public void yummy() {
  36. this.dummy();
  37. }
  38. });
  39.  
  40. check.activate(this_ -> this_.dummy());
  41.  
  42. @FunctionalInterface
  43. public interface Lambda {
  44. void yummy(Lambda this_);
  45.  
  46. default void yummy() {
  47. yummy(this);
  48. }
  49.  
  50. default void dummy(){
  51. System.out.println("Call this..");
  52. }
  53. }
  54.  
  55. default String add(String b)
  56. {
  57. return "added content "+b;
  58. }
  59.  
  60.  
  61. default String getResult()
  62. {
  63. String c = init(this);
  64. return c;
  65. }
  66.  
  67. public static void main(String[] args)
  68. {
  69.  
  70. Value v = a -> a.add("inpout"); // here I am calling add method in Value interface.
  71. String c = v.getResult();
  72.  
  73. System.out.println(c);
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement