Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Tagged as

Im getting a different result than the compiler when tracing array excercise

, 10 Nov 2012 CPOL
when i trace the code im getting 1,3,5,7 for the answer but the compiler prints 1,3,6,10im having trouble understanding how this happens could anyone explain int [] a= new int[5]; // create arrayfor (int i =1; i<=4; i++) { a[i]=a[i-1]+i; System.out.print(a[i]+" ");}



Compare Revision Minor Date Status Editor
2 - publicly available No 10-Nov-12 19:23 Available TorstenH.
Updates in content.
1 No 10-Nov-12 18:32 Available diego14567


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author


United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150414.1 | Last Updated 10 Nov 2012
Article Copyright 2012 by diego14567
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid