JavaFormatter Free Online Java Formatter
Conventions

Java Line Wrapping Rules: How to Indent Continuation Lines

2026-08-26 · 5 min read

Ask two Java developers how to wrap a long line and you get three opinions. Line wrapping is the part of formatting where style guides genuinely disagree, where editors insert different defaults, and where most files quietly fall apart. This guide collects the rules that actually matter, shows how the two big style guides differ, and explains continuation indent, the setting most people never notice until it ruins a diff.

Why Line Length Limits Exist

The compiler does not care if a line has 80 or 800 characters. Line limits exist for people: code review happens in narrow panes, two files sit side by side, and long lines force horizontal scrolling that hides structure. The common limits are 80 from the classic Oracle conventions, 100 from Google Java Style, and 120, the IntelliJ default. The number matters less than the consistency: pick one, configure it, and stop arguing, the same way teams settle spaces versus tabs.

Rule 1: Where to Break the Line

When an expression must wrap, the break goes at the highest syntactic level, not mid-name. Google style breaks before the operator; the classic Oracle guide broke after it. Compare:

// break before the operator (Google)
int total = basePrice
    + shipping
    - discount;

// break after the operator (classic Oracle)
int total = basePrice +
    shipping -
    discount;

Both are readable. Mixing both in one file is not. Choose one and let the formatter apply it, which is exactly what the conventions that still matter recommend for every formatting decision.

Rule 2: One Argument per Line When Wrapped

When a call does not fit, the standard move is one argument per line, indented to line up with the opening parenthesis or by one continuation indent:

Invoice invoice = new Invoice(
    customerName,
    LocalDate.now(),
    PaymentTerms.NET_30);

Filling lines with as many arguments as fit looks compact but produces the worst kind of diff: add one argument and every line of the call changes.

Rule 3: Method Chains and Streams

Chained calls wrap with the dot starting each line, so each step of the pipeline is visible:

List<String> names = customers.stream()
    .filter(c -> c.isActive())
    .map(Customer::getName)
    .sorted()
    .collect(Collectors.toList());

Google style indents continuation lines by 4 spaces here, IntelliJ by 8. Both make the pipeline scannable top to bottom, which is the entire point.

Rule 4: Ternaries and Constructors

A long ternary wraps with each part on its own line: condition, question mark branch, colon branch. Long constructor argument lists follow the one-argument-per-line rule above. The goal in both cases is the same: each line carries one idea, so a reader can scan the structure before reading the detail.

What a Formatter Does About All This

The online Java formatter re-indents wrapped lines to a consistent continuation depth, which fixes the most common damage: continuation lines at random depths after a merge. For full wrapping policy, configured to one limit and one break style, IDE settings or the build formatter own the job. The practical workflow: fix structure first, then wrapping, which is the same order as the quick cleanup workflow.

Frequently Asked Questions

What is the maximum line length for Java code?

There is no compiler limit. The classic Oracle conventions suggest 80 characters, Google Java Style uses 100, and IntelliJ defaults to 120. Pick one limit per project and let the formatter enforce it.

Should operators go at the end or the start of a wrapped line?

Google style breaks before the operator; the classic Oracle guide broke after it. Teams accept either, as long as it is consistent across the whole codebase.

What is a continuation indent?

It is the extra indent used for lines that wrap inside a statement, deeper than the normal block indent. IntelliJ defaults to 8 spaces for continuation lines, Google style uses 4 for most wraps.

More Free Developer Tools

DevToolCore

JSON formatter, regex tester, Base64, URL encoder, and 15+ more dev tools.

FontGenerator

14 Unicode font styles for social media, Discord, and anywhere you paste text.

CyberFengShui

Online Feng Shui compass with flying star analysis and AI interpretation.