java - How to toString() a List like this one : List<Option>? -


suppose have list of object called option :

list<option> opts = arraylist<option>(); 

i have override tostring() object option.

when opts.tostring() means tostring list , unnecessary commas ,,,,,.

i change that. please, there way better for-looping inside list tostring each element ? hope clear.

i guess not idea override tostring of arraylist, can create own print function in utility class of application:

public static string mytostring(list<?> list) {     stringbuilder stringlist = new stringbuilder();     string delimiter = " ";     (int c = 0; c < list.size(); c++) {         stringlist.append(delimiter);         stringlist.append(list.get(c));     }     return stringlist.tostring(); } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -