package jcf_set.example;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

public class InteriRipetuti {
	
	public static void main(String[] Args) {
		
	}
	
	public void run() {
		int N = 20;
		int MAX_INT = 50;
		
		// HASHSET
		Set<Integer> hashset = new HashSet<Integer>();
		
		// Genero i numeri casuali inserendoli in nel set di hashset
		Random generator = new Random();
		for (int i = 0; i < N; i++) {
			Integer x = generator.nextInt(MAX_INT + 1);
			if (!hashset.add(x)) {
				System.out.println("[NON INSERITO] Causa: Intero ripetuto: " + x);
			} else System.out.println("Intero inserito: " + x);
		}
		
		// Stampa di hashset
		System.out.println("Hashset");
		for (Integer x : hashset)
	}
	
}
