why doesn't it overwrites the array

Reply

Join Date: Jun 2009
Posts: 28
Reputation: anusha88 is an unknown quantity at this point 
Solved Threads: 0
anusha88 anusha88 is offline Offline
Light Poster

why doesn't it overwrites the array

 
0
  #1
Jul 6th, 2009
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'


  1.  
  2.  
  3.  
  4.  
  5.  
  6. class tryy
  7. {
  8. public static void main(String args[])
  9. {
  10. 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};
  11.  
  12.  
  13. for(int i=0;i<array.length;i++)
  14. {
  15. for(int j=0;j<(int)(array.length/6);j=j+2)
  16. {
  17. double numbers[]=new double[2];
  18. System.arraycopy(array,j,numbers,0,2);
  19. for(int u=0;u<numbers.length;u++)
  20. {System.out.println(numbers[u]);}
  21.  
  22. }
  23. }
  24. }
  25. }
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,600
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 460
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: why doesn't it overwrites the array

 
0
  #2
Jul 6th, 2009
Remove outer loop and repeat for(j=0...) loop six times.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 28
Reputation: anusha88 is an unknown quantity at this point 
Solved Threads: 0
anusha88 anusha88 is offline Offline
Light Poster

Re: why doesn't it overwrites the array

 
0
  #3
Jul 6th, 2009
done..thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC