package com.vcarecity.cvs.service.impl; import java.util.Arrays; class MySQLResultHandlerServiceImplTest { @org.junit.jupiter.api.Test void resultHandler() { String[] h = new String[3]; StringBuffer sb = new StringBuffer(); Object[] rows = new Object[]{1, "test", null}; for (int i = 0; i < rows.length; i++) { Object row = rows[i]; if (row instanceof String) { sb.append("'").append(row).append("'"); } else { sb.append(row); } if (i != rows.length - 1) { sb.append(","); } } System.out.println(sb.toString()); Arrays.fill(h, "%s"); final String join = String.join(",", h); final String value = String.format(join, rows); System.out.println(join); System.out.println(value); } }