From the method List> method() i get the output like this with 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 to store the above result in a pojo class name 'ClassName' which has the following columns col1, col2 and col3, So I try to run the following code as
public void method() {
try {
List<List<String>> list = testDAO.methodName();
List<ClassName> className= new ArrayList<ClassName>();
for (Iterator<List<String>> iterator = list.iterator(); iterator.hasNext();) {
List<String> list2 = (List<String>) iterator.next();
int i = 0;
ClassName className= new ClassName ();
for (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 i got the output as
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 a solution to save the datas in the POJO class 'ClassName'