Code Room
Code reviewMedium
Question
Review this Java that reads an uploaded CSV's bytes, parses the header row, and maps each declared column to its index.
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.
Learn the concepts
Map<String, Integer> headerIndex(byte[] csvBytes) { String text = new String(csvBytes); // file is UTF-8 String firstLine = text.split("\n", 2)[0]; String[] cols = firstLine.split(","); Map<String, Integer> index = new HashMap<>(); for (int i = 0; i < cols.length; i++) { index.put(cols[i].trim(), i); // e.g. "Pr\u00e9nom" -> 0 } return index;}Run or narrate your approach, then ask the coach.