package com.sdufe.domain;
import java.util.ArrayList;
import java.util.List;
class User {
private int num;
public User(int num) {
this.num = num;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
List<User> userList = new ArrayList<User>();
userList.add(new User(0));
User user1 = new User(1);
User user2=new User(2);
userList.add(user1);
userList.add(0, user2);
System.out.println(userList);
System.out.println(userList.size());
for (User user : userList) {
System.out.println("usernum==="+user.getNum());
}
}
}
问题:里面有几个User Instance 运行结果是什么
===================================
不去跑你知道答案吗?
===================================