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.

enter image description here

i see these possibilities.

  1. lststudents empty
  2. getid() returns empty string
  3. 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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -