Code Room
Code reviewMediumcr-g282
Subject Unnecessary allocationLevel Mid–Senior~18 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Review this Java method that renders a CSV body from rows. It works for small exports but a customer report with ~200k rows takes minutes and spikes GC.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjava
String toCsv(List<Row> rows) {    String out = "";    for (Row r : rows) {        out = out + r.id() + "," + r.name() + "," + r.amount() + "\n";    }    return out;}
Run or narrate your approach, then ask the coach.