import java.util.*;
public class Geometry
{
public static void main(String[] args)throws Exception
{
TreeSet ts=new TreeSet();
for(int i=5;i>=0;i--)
{
ts.add(new Integer(i));
}
TreeSet anotherts=(TreeSet) ts.clone();
Iterator it=anotherts.iterator();
while(it.hasNext())
{
System.out.println(it.next());
}
System.out.println("创建TreeSet类");
TreeSet s=new TreeSet(new MyComparator());//MyComparator can't resolved a type?
s.add("aa");
s.add("cc");
s.add("dd");
s.add("bb");
Iterator its=s.iterator();
while(its.hasNext())
{
System.out.println(its.next());
}
System.out.println("第一个元素为:"+s.first());
System.out.println("最后一个元素为:"+s.last());
}
}
怎样使之运行咯?呵呵,刚入门。不太懂哦
public class Geometry
{
public static void main(String[] args)throws Exception
{
TreeSet ts=new TreeSet();
for(int i=5;i>=0;i--)
{
ts.add(new Integer(i));
}
TreeSet anotherts=(TreeSet) ts.clone();
Iterator it=anotherts.iterator();
while(it.hasNext())
{
System.out.println(it.next());
}
System.out.println("创建TreeSet类");
TreeSet s=new TreeSet(new MyComparator());//MyComparator can't resolved a type?
s.add("aa");
s.add("cc");
s.add("dd");
s.add("bb");
Iterator its=s.iterator();
while(its.hasNext())
{
System.out.println(its.next());
}
System.out.println("第一个元素为:"+s.first());
System.out.println("最后一个元素为:"+s.last());
}
}
怎样使之运行咯?呵呵,刚入门。不太懂哦
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货