2.1 HashSet的用法
对象也必须定义hashCode(),比如下面例子2.1.1中的String类中就定义了hashCode方法。 h.add("1"); 但随着Set的增大,它的性能不会大打折扣。这是由Hash的低层结构决定的。HashSet不保证输出的顺序。
例:2.1.1
import java.util.*;
public class TestMark_to_win {
public static void main(String args[]) {
HashSet h = new HashSet();
h.add("1");
h.add("2");
h.add("3");
h.add("4");
System.out.println(h);
}
}
更多请见:https://blog.csdn.net/qq_44639795/article/details/102707052