I have a list of data in the iterator.I want to store it in a string. How can I do it? Here is my code.
List ln = readData(iStepNumber, status, query);
Iterator itr = ln.iterator();
System.out.println("listttt"+ln);
while(itr.hasNext()) {
System.out.println("itr value1 :"+itr.next());
//what to do to store itr.next() in a string
//for example String a=itr.next()?
}
This is what I get in the console
listttt[2017-06-30 23:59:59]
itr value1 :2017-06-30 23:59:59
String.join(",", ln)might be what you're looking for, but then I don't see what's wrong with your current output.