I have an ArrayList with some Strings. I want to store that list of numbers from the ArrayList in a single string separated by a comma like the following.
String s = "350000000000050287,392156486833253181,350000000000060764"
This is my list:
List<String> e = new ArrayList<String>();
e.add("350000000000050287");
e.add("392156486833253181");
e.add("350000000000060764");
I have been trying to do it the following way:
StringBuilder s = new StringBuilder();
for (String id : e){
s.append(id+",");
}
The only problem with this is that this adds a comma to the end and I do not want that.What would be the best way to this?
Thanks
delete/deleteCharAt/setLength
– Extrude