public class Split {
public static void main(String[] args){ } }
String s1=\ +
\ +
\ + \;
String s2[]=s1.split(\); for(int i=0;i 2、 设计一个类Student,类的属性有:姓名,学号,出生日期,性别,所在系等。并生成学 生类对象数组。按照学生的姓名将学生排序输出。使用String类的compareTo方法。 package job1; public class Student { private String name; private int num; private String birth; private String sex; private String sdept; public Student(){ } public Student(String name,int num,String birth,String sex,String sdepet){ } public void setName(String name){ } public String getName(){ return name; this.name=name; this.num=num; this.birth=birth; this.sex=sex; this.sdept=sdept; } this.name=name; public int getNum(){ } public void setNum(int num){ } public String getBirth(){ } public void setBirth(String birth){ } public String getSex(){ } public void setSex(String sex){ } public String getSdept(){ } public void setSdept(String sdept){ } } this.sdept=sdept; return sdept; this.sex=sex; return sex; this.birth=birth; return birth; this.num=num; return num; package job1; import java.util.Comparator; import java.text.CollationKey; import java.text.Collator; public class MyCmp implements Comparator{ public int compare(Object obj1,Object obj2){ } } package job1; import java.util.*; public class TreeText { public static void main(String[] args){ TreeMap map=new TreeMap(new MyCmp()); Collator collator=Collator.getInstance(); CollationKey key1=collator.getCollationKey(obj1.toString()); CollationKey key2=collator.getCollationKey(obj2.toString()); return key1.compareTo(key2); } } map.put(\蒋高登\,\男 CS\); map.put(\蒋稀文\,\男 CS\); map.put(\董骏\,\男 CS\); Set keys=map.entrySet(); Iterator it=keys.iterator(); while(it.hasNext()){ Map.Entry e=(Map.Entry) it.next(); System.out.println(e.getKey()+\+e.getValue()); } 3、 设计一个程序计算2011-05-01日与系统当前日期相差的天数。 package job1; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Days { public static void main(String[] args) throws ParseException{ Date d1=new Date(); SimpleDateFormat format=new SimpleDateFormat(\String s=\Date d2=format.parse(s); } } int days=(int)((d2.getTime()-d1.getTime())/(1000*60*60*24)); System.out.print(\日与系统当前时间相差\天\ 4、使用日历类等相关方法 按截图做出一个日历 参照书本示例,研究其中代码回顾与复习利用Java Swing编程。 参考:以下函数根据输入的年和月计算相应的数字 public void showCalendar(int year,int month){ Calendar cal=Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month-1); //计算当前月一共有多少天 int days=cal.getActualMaximum(Calendar.DAY_OF_MONTH);