I have two Arrays that are initialized as such:
public static double[] arrayweight= new double[100];
public static double[] arraypulse= new double[100];
They are filled with data e.g. 23.0,25.8....etc.
I need to combine the two Arrays into one array of double[]
I have chosen to use the following approach which does not work. Any ideas?
ArrayList <Double> al = new ArrayList<Double>();
// The following methods do not work ;(
al.add((double[]) Global.arrayweight);
al.add(new Double(Global.arraypulse));
You can achieve it using System.arraycopy.
double[] cArray= new double[Arrayweight.length + Arraypulse.length];
System.arraycopy(Arrayweight, 0, cArray, 0, Arrayweight.length);
System.arraycopy(Arraypulse, 0, cArray, Arrayweight.length, Arraypulse.length);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With