package com.g.v.jihe;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
/**
* @author
*/
public class CollectionTest {
private int age;
@Test
public void test1(){
Collection coll = new ArrayList();
coll.add("hh");
coll.add("mm");
//遍历Iterator方式
Iterator iterator = coll.iterator();
while (iterator.hasNext()){
System.out.println(iterator.next());
}
System.out.println("**********");
//遍历foreach方式
for (Object obj:coll){
System.out.println(obj);
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CollectionTest that = (CollectionTest) o;
return this.age == that.age;
}
@Override
public int hashCode() {
return age;
}
}