guava学习笔记一

/ 技术 / 无站内评论 / 286浏览
//自带非空判断
          String s2=null;
        //System.out.println(s2.isEmpty()); 报错
        System.out.println(Strings.isNullOrEmpty(s2));

        //复制文件
        /*File from;
        File`tos;
        Files.copy(from,tos); //注意,只用了一行代码噢*/

        //创建集合
        Map<String,Integer> map= Maps.newHashMap();
        List<Object> list = Lists.newArrayList();
        Set<Object> set = Sets.newHashSet();

        // 自带非空判断对象比较
        System.out.println(Objects.equals("a", null));

        //比较
        int result = ComparisonChain.start()
                .compare(1, 2)
                .compare(2, 3)
                .compare(1.2d, 1.2f)
                .compare(5, 4).result();

        System.out.println(result);

//创建不可变集合 优化性能
ImmutableList<String> of = ImmutableList.of("a", "b", "c", "d");
for(String s:of){
    System.out.println(s);
}

    }
召唤蕾姆
琼ICP备18000156号

鄂公网安备 42011502000211号