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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -