package com.sf._02_list.demo1;

import java.util.ArrayList;

public class Test {

    public static void main(String[] args) {
        /**
         * 练习list 的api
         *
         * 需求
         * 1定义一个Employee 类  类中有id  name   age
         * 2 创建ArrayList, 往集合中添加三个employee
         * 3 删除索引为0 元素
         * 4 修改索引1 元素
         * 5 查询索引为2 元素
         * 6 查询集合数量
         */
        ArrayList<Employee> list = new ArrayList<>();
        list.add(new Employee(1L,"zhangsan",10));
        list.add(new Employee(2L,"lisi",11));
        list.add(new Employee(3L,"wangwu",12));
//        for (Employee employee : list) {
//            System.out.println(employee);
//        }
        // 删除索引为0 元素
//        list.remove(0);
//        for (Employee employee : list) {
//            System.out.println(employee);
//        }
        // 修改索引为1 元素
//        list.set(1,new Employee(3L,"zhaoliu",30));
//        for (Employee employee : list) {
//            System.out.println(employee);
//        }
        // 查询索引为2 元素
        System.out.println(list.get(2));
        System.out.println("集合数量为:"+list.size());
    }
}
