반응형
public class Memset{
private HashSet<Member> hashSet;
public Memset()
{
hashSet = new HashSet<Member>();
}
public void add(Member member)
{
hashSet.add(member);
}
public boolean remove(int id)
{
Iterator <Member> ir = hashSet.iterator();
while(ir.hasNext())
{
Member member = ir.next();
if(member.getMemberId() == id)
{
hashSet.remove(member);
return true;
}
}
System.out.println(id+"존재 x");
return false; }
public void showAll()
{
for(Member m : hashSet)
{
System.out.println(member);
}
System.out.println();
}
hashSet에 저장된 객체를 모두 보여주는 함수.
반응형