Print a Java Object List

Asked

Viewed 443 times

0

When making a filter of courses belonging to a given shift , the correct thing would be to make a foreach by walking through an object , but by doing so he gives an error ';' expected , I didn’t quite understand why he gave this and adding the ; as he is of error also...

@RequestMapping("/filtrarCursos/{idTurno}/{idTipoCurso}")
public String filtrarCursos(@PathVariable("idTurno") Long idTurno, @PathVariable("idTipoCurso") String idTipoCurso) {
    try {

        List<CursoTurno> cursoId = cursoTurnoRepository.findByTurnoId(idTurno);
        for ( c : cursoId ) {

        }

        System.err.print( "\n--- kingSizeCursos: "+cursoId.size());
        System.err.print( "\n--- idTurno: "+idTurno);
        System.err.print( "\n--- idTipoCurso: "+idTipoCurso);
    } catch (Exception e) {
        mensagem = mensagemErro(e.getMessage());
    }

    return "";
}
  • In his for you did not put the object type c.

  • When I type, it’s a problem due to Cursoid returning an object =x

1 answer

2


You need to "type" the foreach:

List<CursoTurno> cursoId = cursoTurnoRepository.findByTurnoId(idTurno);
for(CursoTurno c : cursoId) {

}
  • 1

    It worked out , thank you very much , had not even thought about it , razor beginner =]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.