Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. @FunctionalInterface
  2. interface IStringLength {
  3.  
  4. public abstract int measureStringLength(String string);
  5.  
  6. }
  7.  
  8. public class LambdaExercise {
  9.  
  10. private IStringLength lambda = (string) -> string.length();
  11.  
  12. public IStringLength getLambda() {
  13. return lambda;
  14. }
  15. public void setLambda(IStringLength lambda) {
  16. this.lambda = lambda;
  17. }
  18.  
  19. public static void main(String[] args) {
  20.  
  21. String s = "Hello World";
  22. int sLength = new LambdaExercise().getLambda().measureStringLength(s);
  23. System.out.println(sLength);
  24.  
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement