My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.lineadecodigo.java.basico;

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

/**
* @file ForEach.java
* @version 1.0
* @author Linea de Codigo (http://lineadecodigo.com)
* @date 01-febrero-2009
* @url http://lineadecodigo.com/2009/02/02/bucle-for-each-en-java/
* @description Utilizar de bucle for-each
*/

public class ForEach {

public static void main(String[] args) {

// Listar un array
String array[] = {"Avila", "Burgos", "León", "Palencia", "Salamanca", "Segovia", "Soria", "Valladolid", "Zamora"};

for (String elemento: array)
System.out.println(elemento);

// Listar una colección
List<String> list = new ArrayList<String>();
list.add("Victor");
list.add("Amaya");
list.add("Julio");

for (String nombre: list)
System.out.println(nombre);

}

}

Change log

r99 by vcuervo on Jan 31, 2009   Diff
Bucle For-Each en Java
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 858 bytes, 36 lines
Powered by Google Project Hosting