Convert java List to object using collection -Stream -
from method list> method() output 3 elements
[123456, 10, 03-jan-16] [956233, 20, 03-jan-16] [254656, 30, 03-jan-16] [455556, 40, 04-jan-16] [548566, 50, 03-jan-16] [215663, 60, 03-jan-16]
i need store above result in pojo class name 'classname' has following columns col1, col2 , col3, try run following code
public void method() { try { list<list<string>> list = testdao.methodname(); list<classname> classname= new arraylist<classname>(); (iterator<list<string>> iterator = list.iterator(); iterator.hasnext();) { list<string> list2 = (list<string>) iterator.next(); int = 0; classname classname= new classname (); (iterator<string> iterator2 = list2.iterator(); iterator2.hasnext();) { string string = (string) iterator2.next(); /* system.out.println(string); */ if (i == 0) classname.setcol1(string); else if (i == 1) classname.setcol2(long.parselong(string)); else if (i == 2) classname.setcol3(string); i++; } odhs.add(classname); system.out.println(classname); // system.out.println(classname.col2()); // system.out.println(classname.col3()); } // system.out.println("total size: "+ odhs.size()); } catch (exception e) { e.printstacktrace(); } }
but got output
com.project.model.classname@61af1510 com.project.model.classname@37af1f93 com.project.model.classname@778d82e9 com.project.model.classname@408e96d9 com.project.model.classname@59901c4d com.project.model.classname@168cd36b com.project.model.classname@d8d9199 com.project.model.classname@3901f6af
please provide solution save datas in pojo class 'classname'
your class odh
must override tostring
method.
Comments
Post a Comment