A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

public class ArrayListDemo2 {
        public static void main(String[] args) {
                ArrayList array = new ArrayList();

                Student s1 = new Student("乔峰", 40);
                Student s2 = new Student("虚竹", 36);
                Student s3 = new Student("段誉", 28);

                array.add(s1);
                array.add(s2);
                array.add(s3);

                Iterator it = array.iterator();
                while (it.hasNext()) {
                        Student s = (Student) it.next();
                        System.out.println(s.getName() + "***" + s.getAge());
                }

                System.out.println("-------------");

                for (int x = 0; x < array.size(); x++) {
                        Student s = (Student) array.get(x);
                        System.out.println(s.getName() + "***" + s.getAge());
                }
        }
}

7 个回复

正序浏览
顶顶顶:victory:
回复 使用道具 举报
路过  学习
回复 使用道具 举报
难怪乔峰能到老大
回复 使用道具 举报
刚学习的这个
回复 使用道具 举报
难怪段誉最帅^ _ ^
回复 使用道具 举报
不错(⊙o⊙)哦
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马