• LinkedHashMap,TreeMap和Hashtable子类Properties


    1 LinkedHashMap:使用链表去维护添加进Map中的顺序。故遍历Map时,总是按照添加的顺序遍历

    2 按照添加进Map中的元素的key的制定属性进行排序。要求:key是同一个类的对象。 分为:自然排序vs定制排序。代码和TreeSet基本一样

    3 Hashtable:古老的实现类,不建议使用。Properties:常用来处理属性文件,键和值都是String类型的

    例如:

    public class TestProperties{
    @Test
         public void test1()throws FileNotFoundException,IOException{
           Properties pro = new Properties();
           pro.load(new FileInputStream(new File("file1")));
           String s1 = pro.getProperty("aaa");
           String s2 = pro.getProperty("aaa");
           System.out.println(s1+"
    "+s2);
    }
    }

    file1:

    aaa = 234
    bbb = 242
    ccc = 231

    结果:

    234

    234

  • 相关阅读:
    poj1330 Nearest Common Ancestors
    poj3237 Tree
    spoj2798 QTREE3 Query on a tree again!
    spoj913 QTREE2 Query on a treeⅡ
    自动类型转换
    js "+"连接符号
    js parseFloat
    js字符串与数字的运算
    js prompt
    js数组排序
  • 原文地址:https://www.cnblogs.com/yjtm53/p/4149898.html
Copyright © 2020-2023  润新知