- package com.heima.zuoye;
- import java.util.ArrayList;
- import com.heima.bean.Person;
- public class Demo4_StrongFor {
- public static void main(String[] args) {
- //demo1();
- ArrayList<String> list = new ArrayList<>();
- list.add("lalala");
- list.add("hahaha");
- list.add("hehehe");
- list.add("eeeeee");
-
- for(String s:list) {
- System.out.println(s);
- }
- }
- public static void demo1() {
- ArrayList<Person> list = new ArrayList<>();
- list.add(new Person("张三",23));
- list.add(new Person("李四",24));
- list.add(new Person("王五",25));
- list.add(new Person("赵六",26));
-
- /*for(Person person:list) {
- System.out.println(person);
- }*/
- for (Person person : list) {
- System.out.println(person);
- }
- }
- }
复制代码 |
|