title: length of Array of Objects in Java
body: <p>I want to calculate how many records hold an Array of Objects . here's my code:</p>
  
  <pre><code>public class PoS {
      int id;
      String name;
      double pos_gps_lat;
      double pos_gps_long;
  
      public PoS(int id, String name,double pos_gps_lat, double pos_gps_long) {
          this.id=id;
          this.name=name;
          this.pos_gps_lat=pos_gps_lat;
          this.pos_gps_long=pos_gps_long;
  
      }
  }
  </code></pre>
  
  <p>I added only one (1) record as fellow        </p>
  
  <pre><code>PoS pos[]=new PoS[1];   // updated as requested in comments
  pos[0]=new PoS(1,"test",12.123456, 12.123456); 
  </code></pre>
  
  <p>But i get 4 as a result :</p>
  
  <pre><code>  System.out.printf(pos.length);
  </code></pre>
  
  <p>Question 1:
  How i can get the number of records and <strong>not</strong> the number of elements that an Array of Objects  contains?</p>
  
  <p>Question 2:
  I'm going to use over 10 K records, is Array of Objects the best option in term of performance?</p>