this program divides the array into 6 segments of two elements each.but with each iteration the new array is not overwritten and it keeps displaying the first two values of the array 'array'
class tryy { public static void main(String args[]) { double array[]={12.43,34.34,4.432,9.433,4.787,4.2987,57.93,4.279,8.379,83.472,8.9867,879.56}; for(int i=0;i<array.length;i++) { for(int j=0;j<(int)(array.length/6);j=j+2) { double numbers[]=new double[2]; System.arraycopy(array,j,numbers,0,2); for(int u=0;u<numbers.length;u++) {System.out.println(numbers[u]);} } } } }
Remove outer loop and repeat for(j=0...) loop six times.
done..thanks