我用LinkedList<Log> 存储Log对象,对于要存入的两个对象如:xinhuanetindex_News|新华网|即时要闻|null|http://www.news.cn/jsyw.htm|网站有成功也有失败,是版面问题
xinhuanetindex_News|新华网|新闻中心|null|http://www.xinhuanet.com/newscenter/index.htm|网站有成功也有失败,是版面问题存入前是上面那两个,这两个对象是不同的,存入后遍历却出现xinhuanetindex_News|新华网|新闻中心|null|http://www.xinhuanet.com/newscenter/index.htm|网站有成功也有失败,是版面问题
xinhuanetindex_News|新华网|新闻中心|null|http://www.xinhuanet.com/newscenter/index.htm|网站有成功也有失败,是版面问题这两个对象变成一样的了,想了半天没想出个所以然?求解
xinhuanetindex_News|新华网|新闻中心|null|http://www.xinhuanet.com/newscenter/index.htm|网站有成功也有失败,是版面问题存入前是上面那两个,这两个对象是不同的,存入后遍历却出现xinhuanetindex_News|新华网|新闻中心|null|http://www.xinhuanet.com/newscenter/index.htm|网站有成功也有失败,是版面问题
xinhuanetindex_News|新华网|新闻中心|null|http://www.xinhuanet.com/newscenter/index.htm|网站有成功也有失败,是版面问题这两个对象变成一样的了,想了半天没想出个所以然?求解
List<Log> listBoard=LogProperty.getBoard(path,list.get(i).getConfig()); for(int n=0;n<listBoard.size();n++){
log.setConfig(listBoard.get(n).getConfig());
log.setBoard(listBoard.get(n).getBoard());
log.setUrl(listBoard.get(n).getUrl());
log.setWebName(jdbc.getWebName(list.get(i).getConfig(),"61.155.9.142"));
log.setAnalysis("网站有成功也有失败,是版面问题");
System.out.println(log.toString()+"|");
list3.add(log);
}
}
上面这个是插入前的代码。
List<Log> list=LogProperty.getParserFailedWeb(path);
System.out.println(list.size());
for(int i=0;i<list.size();i++){
System.out.println(list.get(i).toString());
}
上面这个是遍历的代码。
Log log=new Log();
log.setXX..
log.setXX
list3.add(log);
}
然后list里面2个引用都指向这个对象;不知道我理解的对不对
List<Log> list=LogProperty.getParserFailedWeb(path);楼主你存取的list对象是不是不是同一对象。 还有上面这两句话能解释下么
这里的i在哪里定义的?循环里面是n啊,代码不全