• Java---集合


    arraylist

    package com.zit;
    
    import java.util.ArrayList;
    
    public class Listdemo {
        public static void main(String[] args) {
            var list = new ArrayList<String>();
            list.add("java");
            list.add("mysql");
            list.add("css");
            list.add(".net");
            list.add("sql-sever");
            list.add("ori_cal");
    //      list.clear();
    //        list.remove("java");
    //       list.remove(3);
            list.indexOf("java");
            list.size();
    
            for (String str : list) {
                System.out.print(str + " ");
            }
            list.forEach(System.out::println);
            System.out.println("------------------------------");
    
            list.stream().sorted().forEach(System.out::println);
            System.out.println("------------------------------");
            /* for (String str : list) {
                if (str.contains("s")) {
                    System.out.println(str);
                }
            }*/
            list.stream().filter(e->e.contains("s")).forEach(System.out::println);
            System.out.println("-----------------------");
            list.forEach(e->{
                if(e.contains("s")) {
                    System.out.println(e);
                }
            });
    
        }
    }

    hashset

    public class Setdemo {
        public static void main(String[] args) {
            var list = new HashSet<String>();
            list.add("java");
            list.add("mysql");
            list.add("css");
            list.add(".net");
            list.add("sql-sever");
            list.add("ori_cal");
            //list.remove("java");
            //list.clear();
            //list.isEmpty();
            System.out.println(list);
            list.stream().sorted().forEach(System.out::println);
            list.stream().filter(e -> e.contains("s")).forEach(System.out::println);
        }

    hashmap

    public static void main(String[] args) {
            HashMap<String, String> list = new HashMap();
            list.put("ha", "河南");
            list.put("hn", "湖南");
            list.put("bj", "北京");
            list.put("sh", "上海");
            //list.clear();
            //list.remove("ha");
            list.isEmpty();
            list.containsKey("ha");
            list.containsValue("河南");
            list.keySet();//键集合
            list.values();//值集合
            list.size();
            list.forEach((key, value) -> {
                System.out.println(key);
                System.out.println(list.get(key));
                System.out.printf("list['%s']=%s
    ",key,value);
            });
            for (String s : list.keySet()) {
                System.out.println(s);
                System.out.println(list.get(s));
            }
            list.keySet().forEach(e -> {
                System.out.println(e);
                System.out.println(list.get(e));
            });
            list.keySet().forEach(System.out::println);
        }

    properties

    public static void main (String[] args) throws IOException {
            Properties p = new Properties();
            p.put("db","mydb");
            p.put("user","root");
            p.put("password","root");
            p.put("time","now");
            System.out.println(p.size());
            System.out.println(p.get("password"));
            System.out.println(p.getProperty("password"));
            p.keySet();
            p.values();
            p.store(new FileWriter("c:/my.properties"),"");
            System.out.println("-----------------------------");
            //读取my.peoperties中的内容
            p.load(new FileReader("c:/my.properties"));
            p.forEach((key,value)-> {
                System.out.println(key);
                System.out.println(value);
            });
        }
  • 相关阅读:
    BZOJ1880: [Sdoi2009]Elaxia的路线(最短路)
    「BZOJ1433」[ZJOI2009] 假期的宿舍(二分图,网络流)
    BZOJ 1061 [Noi2008]志愿者招募(费用流)
    [BZOJ2879][Noi2012]美食节(费用流)
    bzoj 1834 [ZJOI2010] network 网络扩容(费用流)
    BZOJ2668:[CQOI2012]交换棋子(费用流)
    bzoj1070【SCOI2007】修车(费用流)
    【BZOJ 1877】 [SDOI2009]晨跑(费用流)
    SQLite_Home
    GeoMesa-单机搭建
  • 原文地址:https://www.cnblogs.com/zxwen/p/9675842.html
Copyright © 2020-2023  润新知