A Java constructor initializes a newly created object. It can also have side effects or throw exceptions, so a `new` expression may occasionally be used only for registration or validation. That flexibility is risky: creating an object and discarding it usually means a missing assignment, return, or `throw`. section 2.12
Creating an exception is not throwing it
`new IllegalArgumentException("Value is negative");` merely constructs an exception object. Unless it is thrown, it is silently discarded and execution continues. Prefer `throw new IllegalArgumentException(...)` when validation must stop the method. section 2.12
Constructor references can hide which overload receives a functional-interface argument. In `contents.computeIfAbsent(fileName, StringBuilder::new)`, the map key is passed to `StringBuilder(String)`, so each builder begins with its filename. Use `s -> new StringBuilder()` when an empty builder is intended; converting a reference to a lambda makes the passed argument visible. section 2.13
A char selects capacity, not content
`new StringBuilder('[')` invokes `StringBuilder(int)`: the character is widened to its numeric value and becomes initial capacity, rather than initial text. Use `new StringBuilder("[")` or create an empty builder and append the character. Static analysis can reliably flag this pattern. section 9.1
Avoid initializer-related mistakes by following these rules:
- Keep constructor side effects and complex validation rare, so discarded `new` expressions are suspicious and can be linted. section 2.12
- Make constructor-reference inputs explicit with a lambda when overload selection or ignored arguments are unclear. section 2.13
- Prefer string literals over character literals when supplying initial `StringBuilder` content, and test user-visible messages. section 9.1
- Treat object construction separately from class initialization: field initializers run in declaration order, while circular class initialization can expose null values or deadlock across threads. section 3.9.3
StringBuilder sb = new StringBuilder('['); #1
sb.append(value);
sb.append(']');
This short call isolates overload selection: the character literal is converted to an integer capacity instead of becoming builder content. section 9.1








