-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
  • 11
  • 2

1 Answers1

-1

In a word, yes.

E.g.:

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

int result = f.apply(1);
Mureinik
  • 277,661
  • 50
  • 283
  • 320