I want to group the elements from 4 to 4 in java.
Each question has 4 sub-questions, so those 4 sub-questions belong to you.
String[] preguntas = request.getParameterValues("pregunta[]");
String[] subpreguntas = request.getParameterValues("subpregunta[]");
int i = 0;
//Recorro todas las sub preguntas.
for (int j = 0; j < subpreguntas.length; j++) {
//Cada pregunta tiene 4 subpreguntas, por tanto hay que agrupar.
if (j % 4 == 0) {
co.Insertar_Sub_pregunta(i, subpreguntas[j]);
} else {
co.Insertar_pregunta(i, preguntas[i]);
i++;
}
}
Insert the questions well, but do not sub-questions, besides I do not have the id of questions in 3, can you help me to group in 4?