hashset treeset
package week02;
import java.util.*;
public class 明明的随机数 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
Set hashSet = new HashSet<>();
int []arr=new int [m];
for(int j = 0; j < m; j ++)
{
arr[j] = sc.nextInt();
}
for(int i = 0; i < arr.length; i++)
{
hashSet.add(arr[i]);
}
System.out.println(hashSet.size());
TreeSet treeSet = new TreeSet();
treeSet.addAll(hashSet);
}
}

浙公网安备 33010602011771号