up previous next contents
Next: Labels Up: Flow control and loops Previous: while and do-while   Contents

for

  • Used to loop over a range of values from beginning to end.
        for (init-expr; boolean-expr; incr-expr)
           statement
    
  • Typically used to iterate a variable over a range of values.
        char ch[] = new char[s.length()];
        for (int i=0; i<s.length(); i++)
        {
           ch[i] = s.charAt(i);
        }
    


up previous next contents
Next: Labels Up: Flow control and loops Previous: while and do-while   Contents