数据初始化细节问题

 

比较两种形式:
	public String group[]={"计科","基础","网工","信工","九实验楼","学院领导","后勤保障"};
	
	private DataDeal dataDeal=new DataDeal();
	
	public void setMeetingRoom(){
		Meeting meeting;
		for(int i=0;i<group.length;i++){
			meeting=new Meeting();
			System.out.println(" "+group[i]);
			meeting.setMeetingID(i);
			meeting.setMeetingName(group[i]);
			meetingList.add(meeting);
		}
		for(int k=0;k<meetingList.size();k++){
			System.out.println("单位分别是:"+meetingList.get(k).getMeetingName());
	}

输出结果一次是:

计科","基础","网工","信工","九实验楼","学院领导","后勤保障

但是如果改成这样的话:
public List<Meeting> meetingList=new ArrayList<Meeting>();
	
	public String group[]={"计科","基础","网工","信工","九实验楼","学院领导","后勤保障"};
	
	private DataDeal dataDeal=new DataDeal();
	
	public void setMeetingRoom(){
		Meeting meeting=new Meeting();
		for(int i=0;i<group.length;i++){
			//meeting=new Meeting();
			System.out.println(" "+group[i]);
			meeting.setMeetingID(i);
			meeting.setMeetingName(group[i]);
			meetingList.add(meeting);
		}
		for(int k=0;k<meetingList.size();k++){
			System.out.println("单位分别是:"+meetingList.get(k).getMeetingName());
	}

 输出结果全部是 :

后勤保障 后勤保障 后勤保障 后勤保障 后勤保障 后勤保障 后勤保障

小小的区别,搞了半个多小时。。。。。。。。。
posted @ 2012-02-24 22:46  java_li  阅读(141)  评论(0编辑  收藏  举报