# Are Java 8 Lambdas Closures?

DevFeed: [Are Java 8 Lambdas Closures?](<https://devfeed.tech/articles/are-java-8-lambdas-closures-32211.md>)

Original publisher: [Read original article](<https://bruceeckel.com/2015/10/17/are-java-8-lambdas-closures/>)

Author: Bruce Eckel

Published: 2015-10-17T00:00:00Z

Content type: article

Language: en

Sources: [Bruce Eckel - Computing Thoughts](<https://devfeed.tech/sources/bruce-eckel-computing-thoughts.md>)

Topics: [Closure](<https://devfeed.tech/topics/closure.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>)

Tags: [2015](<https://devfeed.tech/tags/2015.md>), [abstraction](<https://devfeed.tech/tags/abstraction.md>), [behavior](<https://devfeed.tech/tags/behavior.md>), [bytecode](<https://devfeed.tech/tags/bytecode.md>), [closure](<https://devfeed.tech/tags/closure.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [data](<https://devfeed.tech/tags/data.md>), [external](<https://devfeed.tech/tags/external.md>), [foreach](<https://devfeed.tech/tags/foreach.md>), [function](<https://devfeed.tech/tags/function.md>), [functional](<https://devfeed.tech/tags/functional.md>), [functional-programming](<https://devfeed.tech/tags/functional-programming.md>), [functions](<https://devfeed.tech/tags/functions.md>), [haskell](<https://devfeed.tech/tags/haskell.md>), [java](<https://devfeed.tech/tags/java.md>), [java-8](<https://devfeed.tech/tags/java-8.md>)

## AI overview

Java 8 lambdas can capture local values from their surrounding scope, so they act as closures with a key restriction: captured local variables must be final or effectively final. The article illustrates that a captured integer can be read but not reassigned or updated inside the lambda. A mutable heap object can still be changed through a captured reference, though that introduces mutable shared state concerns if used concurrently. It frames lambdas as a way to create and pass functions at runtime and contrasts this with Python's mutable closed-over variable example.

## Source excerpt

(Significantly rewritten 11/25/2015) Based on what I've heard, I was surprised to discover that the short answer is "yes, with a caveat that, after explanation, isn't terrible." So, a qualified yes. For the longer answer, we must first explore the question of "why, again, are we doing all this?" Abstraction over Behavior The simplest way to look at the need for lambdas is that they describe what computation should be performed, rather than how it should be performed.