# Java Joy: Reapply Function With Stream iterate

In Java we can use the `iterate`

method of the `Stream`

class to create an unbounded stream based on function invocations. We pass to the `iterate`

method an initial value and a function that can be applied to the value. The first element in the unbounded stream is the initial value, the next element is the result of the function invocation with as argument the value from the previous element and this continues for each new element. Suppose we have a function expressed as lambda expression `i → i + 2`

. When we use this lambda expression with the `iterate`

method and a initial value of `1`

we get a stream of `1`

, `1 → 1 + 2`

, `3 → 3 + 2`

, ….