Browse Clojure Foundations for Java Developers

Java Loops vs Clojure Iteration

How iteration changes when you move from mutable loops to function-and-data transformations.

Java’s default iteration tools are loops, indexes, and mutable accumulators. Clojure’s defaults are different:

  • Transform data with map / filter / reduce.
  • Use loop/recur when you need an explicit, local loop.
  • Use recursion directly mainly when the problem shape is naturally recursive (trees, nested structures).

Practical tip: if your Java solution is “for-loop + mutable variable”, your first Clojure translation is usually reduce or a pipeline, not direct recursion.

This section helps you transfer the intent of a loop into a Clojure shape that is idiomatic and easier to test.

In this section

Revised on Friday, April 24, 2026