黑马程序员技术交流社区

标题: list集合中更换对象 [打印本页]

作者: 18463730277    时间: 2015-5-19 22:41
标题: list集合中更换对象
public static void main(String[] args) {
                List list = new ArrayList();

                list.add(new Person("刘一", 15));
                list.add(new Person("陈二", 15));
                list.add(new Person("张三", 15));
                list.add(new Person("李四", 15));
                list.add(new Person("王五", 15));
                list.add(new Person("赵六", 15));
       
                list.add(new Person("田七", 18));
                list.add(new Person("周八", 15));
                list.add(new Person("吴九", 15));
                list.add(new Person("郑十", 15));
                list.add(new Person("马六", 15));

               
                       
                        if ("田七".equals(p.getName())) {
                                it.set(new Person("孙七", 15));
                        }

                }
                System.out.println(list);






欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2