title: java: saving data into an array
body: <p>I'm trying to save some data into an array but unfortunately all the data is saving into array[0] while it shouldn't be like this normally. </p>
  
  <pre><code>int j = 0;
  while ( j &lt; data.length ) { 
      float unbin = binary(data[2*j+1])+binary(data[2*j]);
      float[] bin = new float[] {unbin};
      print(bin);
      j = j + 2;
  }
  </code></pre>
  
  <p>it wrote all the data in <code>bin[0]</code> , what's wrong with my code ? </p>
  
  <p>how could I write :</p>
  
  <pre><code>bin[j] = unbin ? 
  </code></pre>
  
  <p>to save the data in in bin[0] while j = 0 and so on ?</p>
  
  <p>here is the updated  code :</p>
  
  <pre><code>    int j = 0 ;
    float[] bin1 = new float[(data.length/2)];
    while (j &lt; data.length ) {
      if ( data[2*j+2] &gt;= 0  ) {
  
        String unhx =(binary(data[2*j+3])+binary(data[2*j+2])+binary(data[2*j+1])+binary(data[2*j]));
        float unbin = ((float)unbinary(unhx)/100);
        bin1[j/2] = unbin;
        print(bin1[1]);
      }
  
      else if  ( data[2*j+2] &lt; 0 &amp;&amp; data[2*j+3] &lt; 0 ) {
        data[2*j] = (byte)(-data[2*j]);
        data[2*j+1] = (byte)(-data[2*j+1]);
        String unhx =(binary(data[2*j+1])+binary(data[2*j]));
        float unbin = ((-1)*(float)unbinary(unhx)/100);
        bin1[j/2] = unbin;
        print(bin1[1]);
        }
        j = j + 2;
    }
  </code></pre>