实在对不起,网上找到的例子出了些差错,小弟杨小一指正一下。
具体的写在了注释里面
import java.util.ArrayList;
import java.util.List;
import com.wangjialin.server.domain.News;
public class DistinctList {
public static
void main (String args[]){
List newes = new ArrayList();
newes.add(new News(10, "wangjialin", 20));
newes.add(new News(10, "wangjialin", 20));
newes.add(new News(10, "wangjialin", 20));
newes.add(new News(10, "wangjialin", 20));
newes.add(new News(45, "jialingege", 10));
newes.add(new News(89, "android", 50));
News news = new News();
for(int i=0;i
news = newes.get(i);
for(int j=i+1;j
if(news.getTitle().equals(newes.get(j).getTitle())){
}
}
System.out.println(newes.size());
}
}