java中HashSet有什么用,举例说明?

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");
。。。。。。。。。。。。。。。。。
详情黏贴以下网址在地址栏后请进:http://www.mark-to-win.com/index.html?content=JavaBeginner/javaUrl.html&chapter=JavaBeginner/JavaBeginner7_web.html#DefinitionUsageOfHashSet

猜你喜欢

转载自www.cnblogs.com/mark-to-win/p/9698114.html