java - Add variable to ArrayList with custom split -
i'm trying add string arraylist<string> using .add(string). works, separates variables using comma (","). makes problematic me later on when try split string, because of sentences contain commas.
how change comma variable when adding string arraylist?
what doing using tostring method of arraylist print each of element of arraylist separated commas.
solution:
just iterate of arraylist , append them using string builder.
sample:
arraylist<string> s= new arraylist<>(); s.add("adsasd"); s.add("adsasd"); s.add("adsasd"); s.add("adsasd"); stringbuilder s2 = new stringbuilder(); for(string s3 : s) s2.append(s3+" "); system.out.println(s2); result:
adsasd adsasd adsasd adsasd
Comments
Post a Comment