java - How should I concatenate arrays -


this question has answer here:

i using function returns integers

int[] return; 

this function inside loop this

public static int[] toeobarray(double[] tempval)  {     int[] out;     (int = 0; < 10; i++)     {         out = fixarray(tempval[i]);     }     return out; } 

what want new arrays come fixarray add them previous results, in end have big array contain small arrays resulting fixarray

what efficient way of doing this? main problem not knowing how initialize array hold values.

if want work arrays, must first find length of concatenated array. can use system.arraycopy copy small arrays output array.

public static int[] toeobarray(double[] in)  {     int[][] arrays = new int[10][];     int len = 0;     (int = 0; < 10; i++)     {         arrays[i] = fixarray(tempval[i]);         len += arrays[i].length;     }     int[] out = new int[len];     int offset = 0;     (int = 0; < 10; i++)     {         system.arraycopy(arrays[i],0,out,offset,arrays[i].length);         offset += arrays[i].length;     }     return out; } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -