日期:2014-05-20 浏览次数:20823 次
import java.util.ArrayList; import java.util.List; public class DEPT { private long id; private String name; private List depts = new ArrayList(); private List users = new ArrayList(); public User find(long id) { User tmpUser = null; DEPT tmpDept = null; for(int i=0;i<users.size();i++) { tmpUser = (User)users.get(i); if(tmpUser.id == id) return tmpUser; } for(int i=0;i<depts.size();i++) { tmpDept = (DEPT)depts.get(i); tmpUser = tmpDept.find(id); if(tmpUser != null) return tmpUser; } return null; } } class User { public long id; private String name; public DEPT parent; }