Results 1 to 4 of 4
  1. #1
    ahmakki is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Question for loop meaning

    hello
    what does the "char element : alphabet " in this function mean

    private void creerIndex(char[] alphabet)
    {
    int i = 0;
    for (char element : alphabet)
    {
    mapchar.put(element, i++);
    }
    }

  2. #2
    Cemi's Avatar
    Cemi is offline Member
    Join Date
    Apr 2010
    Posts
    36
    Rep Power
    0

    Default

    (char element : alphabet)

    Means it will assign element the value of alphabet once for each value in alphabet. So you will put the entire array alphabet into mapchar.

    The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
    Carpe Diem
    Each day's a gift and not a given right

  3. #3
    ahmakki is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Default

    ok so it's like :
    char element= "";
    for ( int i =0;i< alphabet.length();i++)
    {
    element = alphabet[i];
    mapchar.add(element);
    }

    right ?

  4. #4
    Cemi's Avatar
    Cemi is offline Member
    Join Date
    Apr 2010
    Posts
    36
    Rep Power
    0

    Default

    Correct. :)
    Carpe Diem
    Each day's a gift and not a given right

Similar Threads

  1. Do While Loop
    By s4rd59 in forum New To Java
    Replies: 2
    Last Post: 02-14-2010, 04:29 PM
  2. what is the meaning of "@" in java
    By itaipee in forum New To Java
    Replies: 3
    Last Post: 08-03-2009, 12:17 PM
  3. while-loop stopping on first loop
    By davester in forum New To Java
    Replies: 6
    Last Post: 06-26-2009, 09:46 PM
  4. Exception:Meaning
    By tiger100plus in forum New To Java
    Replies: 2
    Last Post: 11-27-2008, 08:45 AM
  5. Need help with While Loop
    By mrdestroy in forum New To Java
    Replies: 14
    Last Post: 10-20-2008, 03:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •