Advanced for loop in java - Java @ Desk

Thursday, May 16, 2013

Advanced for loop in java












import java.util.ArrayList;
import java.util.List;

public class AdvancedForLoop {
    public static void main(String args[]) {
        List<String> strings = new ArrayList<String>();
        strings.add("First Name");
        strings.add("Last Name");
        strings.add("Age");
        for (String string : strings) {
            System.out.println("Value of string : " + string);
        }
    }
}
Output :
Value : First Name
Value : Last Name
Value : Age






No comments:

Post a Comment