public void add(long x){
  if (arr == null)   arr=new long[4];
 else   if (arr.length == idx)   arr=Arrays.copyOf(arr,arr.length * 2);
  arr[idx++]=x;
}

public void add ( long x ) { if ( arr == null ) arr = new long [ 4 ] ; else if ( arr . length == idx ) arr = Arrays . copyOf ( arr , arr . length * 2 ) ; arr [ idx ++ ] = x ; }
add element to this array .
