Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Java Programming Tutorial - 31 - Enhanced for Loop

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
120,383
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on May 15, 2009

How to use an enhanced for statement in java.

  • likes, 5 dislikes

Link to this comment:

Share to:

Top Comments

  • windows 7 snap feature makes this sooooo much easier to follow

  • Does anyone know of any tools that I could use to review/brush up on the information from these tutorials.

    The tutorials are great but after a day I tend to forget stuff. Anything like worksheets, quizzes, games, questionnaires, exercises or challenges would be perfect and would help a long way.

see all

All Comments (173)

Sign In or Sign Up now to post a comment!
  • I'm confused.

    I can see the for loop is assigning bucky's values to x, plus the total is adding x to itself each loop. But what is controlling which of bucky's values are being added to x?

    The way I'd usually go about this would be to have a counter increasing each loop until a desired figure is reached, with bucky[counter] identifying which of bucky's values I want to access. Counter 0 accessing bucky 0 and then 1, 2, 3 etc.

    I don't see what is controlling this in this videos code.

  • @sublimeftw2 Ubuntu, a linux distribution, also has it. :)

  • Interesting fact: With the "enhanced for loop" you can not change the integer stored in the array.You can only read-access them. I tried, it wouldn't work, I looked it up. So you still have to use the (int x=0;x<100;x++) to change the information stored within the array.

  • @lyrrad999 Initializing is setting a first value for a variable. It's kinda inactive or something before then (Correct me if I'm wrong)

  • @lyrrad999 instead of writing int bucky[5] and then writing out all the values like this:

    bucky[0] = 3

    bucky[1] = 4

    etc...

    You write int bucky[]={3,4,5,6,7};

    the [] after the int (integer) and variable title indicates it's a array. Also, the items in the curly brackets {} are the "bucky[0] = 3"s. If someone can better explain this that'd be great. If you are still confused, watch episode 27 of this series.

  • i know basic array but what is array initiliazer??

  • can someone explain me what int bucky[]={3,4,5,6,7}; ???

  • This doesn't work anymore, could you please make a tutorial on how to do it in JRE 6.0?

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more