viernes, 11 de abril de 2014

Unidad 3 Ejercicio 36: TreeSet de números generados aleatoriamente

package unidad3ejercicio36; import java.util.TreeSet; import java.util.Random; /** * * @author juan */ public class Unidad3Ejercicio36 { /** * @param args the command line arguments */ public static void main(String[] args) { TreeSet conjunto= new TreeSet<>(); Random al = new Random(); while (conjunto.size()<8) { int generado = al.nextInt(10)+1; conjunto.add(generado); System.out.println(generado); } System.out.println("___________________________________________"); for (Integer integer : conjunto) { System.out.println(integer); } System.out.println(conjunto); } }

No hay comentarios: