In Java, lazy evaluation is often performed using object abstractions. In comparison, code evaluation is passed on liberally in functional languages, making laziness a first-class feature.
In Java, if we want the value to be lazily updated, we end its access in the method, where we control the complexity of the evaluation in this method. Some of these constructs are called beans: http://commons.apache.org/beanutils/api/org/apache/commons/beanutils/package-summary.html .
Often you need to create a data structure where all values ββare received lazily, for example. a list where each item is evaluated lazily, or a map where each value is evaluated lazily. To do this, we can subclass and override the get (), put () methods and other applicable methods from the corresponding Java Collection classes. See the java cache hash cache for an example of this strategy.
source share