黑马程序员技术交流社区

标题: 增强for循环 [打印本页]

作者: funny    时间: 2015-9-11 23:08
标题: 增强for循环
package com.wf.impl;

import java.util.ArrayList;

import com.wf.dao.Person;

public class TestFor {

        /**
         * @增强for循环
         */
        public static void main(String[] args) {
                        ArrayList<Person> al = new ArrayList<>();
                        al.add(new Person("张三",23));
                        al.add(new Person("李四",24));
                        al.add(new Person("王五",25));
                        al.add(new Person("赵六",26));
                       
                        for(Person p : al){
                                System.out.println(p.getName() + "..." + p .getAge() );
                        }
        }

}





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