Enhanced array for references. : enhanced for loop « Statements « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Statements » enhanced for loop 
5.4.2.Enhanced array for references.
public class MainClass {
  public static void main(String[] argv) {
    String[] strings = new String[] { "a""asdf""adfadsfa""a" };
    int totalLength = 0;
    for (String s : strings)
      totalLength += s.length();
    System.out.println(totalLength);

  }
}
14
5.4.enhanced for loop
5.4.1.Enhanced for Loops and array: perform identical processing on every element of an array.
5.4.2.Enhanced array for references.
5.4.3.Legal and illegal enhanced for declarations
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.