二 集合Set
集合Set存放的对象是无序,不能重复的,对象之间没有排列顺序,就如数学中的集合一样,具有无序性,互异性。
比如集合A={小明,小红,小军},里面三个人就没有顺序的区别,且是互
异的。
下面是其接口的定义:
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
public class MySet implements Set<Object> {
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public Iterator<Object> iterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public Object[] toArray() {
// TODO Auto-generated method stub
return null;
}
@Override
public <T> T[] toArray(T[] a) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean add(Object e) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean addAll(Collection<? extends Object> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean retainAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean removeAll(Collection<?> c) {
// TODO Auto-generated method stub
return false;
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
}
更多关于集合Set的用法,请看Java基础学习 集合Set的基本使用