why lambda returns identical object

Viewed 115

Almost every book introducing lambda beginning with a Runnable anonymous class, or even mentioned as an alternative to "anonymous class". However, lambda returns the same object while anonymous class returns a new one.

1. Why lambda behaves like this?

2. Why it is designed to be so?

example codes and results

1 Answers

The CallSite is the same in your case, and linkage happens per call-site. I think, to better understand this you need to look at what invokedynamic is. You can read more here.

Related