发发试试

五柳--先生 2012-10-17 05:20:11
public class DirTools
{
public static String getExtensionName(String filename)
{
if ((filename != null) && (filename.length() > 0))
{
int dot = filename.lastIndexOf('.');
if ((dot >-1) && (dot < (filename.length() - 1)))
{
return filename.substring(dot + 1);
}
}
return filename;
}
public static void main(String[] args)
{
String a=getExtensionName("hello.txt");
System.out.print(a);
}
}
...全文
68 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
IEEE_China 2012-10-17
  • 打赏
  • 举报
回复
发错版了吧
五柳--先生 2012-10-17
  • 打赏
  • 举报
回复
import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;

/**
* 定义一个学生类,类里有姓名,学好,成绩,定义五个对象,对这五个对象进行排序并输出
*/

public class Student
{
String name;
int num;
int score;

Student(String name, int num, int score)
{
this.name = name;
this.num = num;
this.score= score;
}

}

class Test implements Comparator
{
@Override
public int compare(Object arg0, Object arg1)
{
Student ss1 = (Student)arg0;
Student ss2 = (Student)arg1;
return ss1.score - ss2.score;
}

public static void main(String[] args)
{
TreeSet ts = new TreeSet(new Test());

Student s1 = new Student("xiaohua", 1,60);
Student s2 = new Student("dahua", 12,45);
Student s3 = new Student("xiaoqiang",6,70);
Student s4 = new Student("xiaowei", 25,100);
Student s5 = new Student("xiaohong",14,80);

ts.add(s1);
ts.add(s2);
ts.add(s3);
ts.add(s4);
ts.add(s5);

Iterator iter = ts.iterator();

while(!ts.isEmpty())
{
if(ts.isEmpty())
{
break;
}
Student s = (Student)iter.next();
System.out.println(s.name+" "+s.num+" "+s.score);
}

}


}

50,545

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧