Foros aprenderaprogramar.com
		Aprender a programar => Aprender a programar desde cero => Mensaje iniciado por: matru en 16 de Marzo 2016, 23:33
		
			
			- 
				Solución propuesta para ejercicio CU00678B del tutorial de programación con Java desde cero:
 
 
 import java.util.ArrayList;
 import java.util.Set;
 import java.util.Iterator;
 import java.util.TreeSet;
 import java.util.HashSet;
 
 public class Implementacion{
 
 public static void main(String []Args){
 
 ArrayList<Set> list = new ArrayList<Set>();
 
 HashSet<String> hashList = new HashSet<String>();
 TreeSet<Integer> treeList = new TreeSet<Integer>();
 
 hashList.add("sol");
 hashList.add("luna");
 hashList.add("suturno");
 
 treeList.add(2);
 treeList.add(8);
 treeList.add(5);
 
 list.add(hashList);
 list.add(treeList);
 
 int i =1;
 Iterator<Set> it = list.iterator();
 System.out.println("Contenido de la lista: ");
 while(it.hasNext()){
 
 System.out.print(it.next()+", ");
 }
 }
 }
 
- 
				Hola matru tu código está bien
 
 Usar estos nombres de variables no es muy recomendable (list, hashList, treeList) porque estás usando palabras clave de Java y esto puede generar confusiones
 
 En tu solución recorres la colección de Set pero no las colecciones de String e Integer. Mira esta solución y fíjate cómo se recorren las colecciones interiores: https://www.aprenderaprogramar.com/foros/index.php?topic=2384.0
 
 Saludos