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\n",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);
        });
    }