Traversing through a custom List of Object java -
i have custom list of entity objects:
list<student> lststudents the list has data database.
how traverse through list , output each data element/column.
i tried this:
for (final student s: lststudents) { outputtdcfile=outputtdcfile+s.getid(); system.out.println(s.getid()); } system.out.println(outputtdcfile); i getting empty result.
issue seems system.out.println(outputtdcfile); though outputtdcfile variable populated values system.out.println fails print it.

i see these possibilities.
- lststudents empty
- getid() returns empty string
- standard output redirected
i think number 1 probable.
solution: either debug code breakpoints or use snippet see if lststudents contains processed.
if (lststudents.isempty()) { system.out.println("lststudents empty"); } else { system.out.println("lststudents not empty, problem elsewhere"); } (final student s: lststudents) { outputtdcfile=outputtdcfile+s.getid(); system.out.println(s.getid()); } system.out.println(outputtdcfile); if nothing displayed, might have problem standard output.
Comments
Post a Comment