java - Creating a 2D array from every 5th element of another array -


alright have hit brick wall , has been killing me 2 days , out of ideas. have program receives data server using companies api. data comes fine , able turn array without issue. however, need secondary array created values in array. let me show you:

data recieved , parsed array: string[] tag data = {d1,d2,d3,d4,d5,d6,d7,d8,d9,d10}  <-----these populated automatically program.  

what need array created d1-d5 , d6-d10, have tried loops , whatnot problem prints first 5 repeatedly.

here code have far:

string[][] tags = null;  try {     //data string var passed method.it return data url.      data = data.substring(61, data.length());     string[] tagname = data.split(";");     string[] secondarray = new string[5];     for(int x = 0; x <= tagname.length; x++) {         for(int = 0; <= 5; i++) {             secondarray[i] = tagname[x];         }         tags[x] = secondarray;     }     data.settagarray(tags); } catch(exception e) {     e.printstacktrace(); } 

this data back:

["lamp_status", null, null, null, null] ["lamp_status", 1, null, null, null] ["lamp_status", 1, 0, null, null] ["lamp_status", 1, 0, 0, null] ["lamp_status", 1, 0, 0, 654722] 

i don't need specific answer need getting in right direction. not sure going on here or how can make work. once again recap need create array of 1-5, 6-10 elements of array.

can try

string[][] secondarray = new string[(tagname.length)/5][5]; for(int x = 0; x<=(tagname.length)/5; x++){     for(int = 0; <= 5; i++)         secondarray[x][i] = tagname[x];  } 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -