• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Problem with Array.

 
Ranch Hand
Posts: 97
C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all!

Not can understand ARRAY with FOR. See:
I use the FOR for show element of ARRAY in a single line.
So, see code:

Code:



The code , is show this:
Elementos: 0
Elementos: 1
Elementos: 2
Elementos: 3
Elementos: 4
Elementos: 5
Elementos: 6
Elementos: 7
Elementos: 8
Elementos: 9

Now, exchange the code FOR:



The code is show different. See:

Elements: 100
Elements: 200
Elements: 300
Elements: 400
Elements: 500
Elements: 600
Elements: 700
Elements: 800
Elements: 900
Elements: 1000

Because ? a explication for that?
Thanks advance!
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "for loop" is used to loop through all the values in the array.

In you first loop you are just displaying the value of the index. If you want to see the value in the array at the given index then you should use:

 
Gustavo Siqueira
Ranch Hand
Posts: 97
C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!
Thanks you!
Problem solved!
 
reply
    Bookmark Topic Watch Topic
  • New Topic