java - Returning a two dimensional array from a list is not indexing properly -



java - Returning a two dimensional array from a list is not indexing properly -

okay have turned list 2 dimensional array. problem output indexes once, if have 10 elements within each list want add together 2 dimensional array, 2 dimensional array have 1 index 'n' number of elements.

for example

i like

{{1,2,3}, {4,5,6}, {7,8,9}}

instead returning:

{1,2,3,4,5,6,7,8,9}

i took suggestions from: convert arraylist 2d array containing varying lengths of arrays

here code:

public static object[][] getordercreatetestcases(){ list<list<string>> list = new arraylist<>(); list<string> values = new arraylist<>(); seek { jsonarray jobject = (jsonarray)getclient().sendget(string.format("get_cases/12&suite_id=136")); for(object obj : jobject){ jsonobject jobj = (jsonobject)obj; values.add(jobj.get("title").tostring()); values.add(jobj.get("id").tostring()); values.add(jobj.get("custom_order_type").tostring()); values.add(jobj.get("custom_product_type").tostring()); values.add(jobj.get("custom_free_shipping").tostring()); values.add(jobj.get("custom_billing_country").tostring()); values.add(jobj.get("custom_shipping_country").tostring()); list.add(values); for(int i=0; i<list.size(); i++){ valuesstring = new object[list.get(i).size()][]; list<string> row = list.get(i); valuesstring[i] = row.toarray(new string[row.size()]); //system.out.print(valuesstring[i]); break; } } } grab (ioexception e) { e.printstacktrace(); } grab (apiexception e) { e.printstacktrace(); } homecoming valuesstring; }

i working dataproviders testng , require homecoming of 2 dimensional object array, can understand why. parsing out info json array (json-simple), adding list, , converting 2 dimensional array. let's grabs info id=5546, next id=4987, next id=3847 , on.. help appreciated

updated...

okay think see why it's doing it's doing still not know how solve problem. loops , begins new set of data, needs create new array.

{{list1}, {list2}, {list3}}

i suppose getordercreatetestcases info provider. if seek way?

public static object[][] getordercreatetestcases() { list<list<string>> list = new arraylist<>(); list<string> values = new arraylist<>(); seek { jsonarray jobject = (jsonarray) getclient().sendget( string.format("get_cases/12&suite_id=136")); (object obj : jobject) { seek { jsonobject jobj = (jsonobject) obj; values.add(jobj.get("title").tostring()); values.add(jobj.get("id").tostring()); values.add(jobj.get("custom_order_type").tostring()); values.add(jobj.get("custom_product_type").tostring()); values.add(jobj.get("custom_free_shipping").tostring()); values.add(jobj.get("custom_billing_country").tostring()); values.add(jobj.get("custom_shipping_country").tostring()); list.add(values); } grab (exception e) { // ignore } } } grab (ioexception e) { e.printstacktrace(); } grab (apiexception e) { e.printstacktrace(); } valuesstring = new object[list.get(i).size()][]; (int = 0; < list.size(); i++) { list<string> row = list.get(i); valuesstring[i] = row.toarray(new string[row.size()]); } homecoming valuesstring; }

java selenium testng

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -