📄 testset.java
字号:
public class TestSet{
public static void main(String[] args){
MySet os1 = new MySet ();
MySet os2 = new MySet ();
//add null, 0, 2, 5
os1.add(new Integer(0));
os1.add(null);
os1.add(new Integer(2));
os1.add(new Integer(0));
os1.add(new Integer(5));
os1.add(null);
os2.add(new Integer(5));
os2.add(new Integer(0));
os2.add(new Integer(2));
os2.add(null);
os2.add(new Integer(5));
os2.add(new Integer(2));
if (os1.include(os2))//os1包涵os2
{
if (os2.include(os1))
{
System.out.println("集合os1和os2相等");
}
else
{
System.out.println("集合os2是os1的子集");
}
}
else//os1不包涵os2
{
System.out.println("集合os1和不包涵os2");
if (os2.include(os1))//os2却包涵os1
{
System.out.println("集合os1是os2的子集");
}
else
{
System.out.println("集合os2和os1不相等");
}
}
System.out.print("os1中的元素:");
os1.print();
System.out.println();
System.out.print("os2中的元素:");
os2.print();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -