Advertisement
JVFabia

Clase 1 ceolecciones set

Sep 23rd, 2020
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. package org.forge;
  2.  
  3. import java.util.*;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         // write your code here
  9.         Scanner in = new Scanner(System.in);
  10.  
  11.         List<Integer> numeros = new ArrayList<>();
  12.  
  13.         for (int i = 0; i < 5; i++) {
  14.             System.out.println("ingrese un numero");
  15.             int n = in.nextInt();
  16.             numeros.add(n);
  17.         }
  18.         Set<Integer> noRepetidos = new HashSet<>();
  19.         noRepetidos.addAll(numeros);
  20.  
  21.         System.out.println(numeros);
  22.         System.out.println(noRepetidos);
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement