Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public class LambdaExpressions {
  2.  
  3. interface Foo {
  4. void bar(Object o);
  5. }
  6.  
  7. static void doo(Foo f) {
  8. f.bar("baz");
  9. }
  10.  
  11. public static void main(String[] args) {
  12.  
  13. doo( x -> {System.out.println(x);});
  14. }
  15.  
  16. }
  17.  
  18. new Foo() {
  19. @Override
  20. public void bar(Object x) {
  21. System.out.println(x);
  22. }
  23. }
  24.  
  25. public static void main(String[] args) {
  26. Foo f = new Foo() {
  27. @Override
  28. public void bar(Object x) {
  29. System.out.println(x);
  30. }
  31. };
  32.  
  33. f.bar("baz");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement