-1

Can we store a lambda expression in java inside a variable and use that variable as a normal function by calling the variable inside the scope it has been declared?

M.barg
  • 31
  • 1
  • 1
  • 3

1 Answers1

-1

In a word, yes.

E.g.:

Function<Integer, Integer> f = x -> x + 1;

int result = f.apply(1);
Mureinik
  • 297,002
  • 52
  • 306
  • 350