//创建Collectio容器对象,存入10个整数,以及2个Date对象。并统计10个数的和
public static void main(String[] args) {
Collection collection = new ArrayList();
for (int i = 1; i <= 10; i++) {
collection.add(i);
}
collection.add(new Date());
collection.add(new Date());
int sum = 0;
for (Object j : collection) {
boolean x = j instanceof Integer;
if (x){
sum += (Integer) j;
}
}
System.out.println(sum);
}