常用类

1、随机输出班上5名学生的学号。

public class random {
public static void main(String[] args) {
for(int s=0;s<5;s++)
System.out.println((int)(Math.random()*55+1));

}
}
运行结果:

2、获取当前系统时间,运用subString()方法,显示年份。

package integer;
import java.util.*;
public class time {
public static void main(String[] args) {
Date date=new Date();
String time = date.toString();
System.out.println("此时系统时间为:"+time);
String year = time.substring(24,28);
System.out.println("此时系统时间的年份为:"+year);
}
}
运行结果:

3、使用Calendar类显示当前日期。

package integer;
import java.util.Calendar;
public class time2 {
public static void main(String[] args) {
Calendar ca1 = Calendar.getInstance();
System.out.print("当前系统时间:");
System.out.print(ca1.get(Calendar.YEAR)+"年");
System.out.print((ca1.get(Calendar.MARCH)+1)+"月");
System.out.print(ca1.get(Calendar.DATE)+"日");
System.out.print(ca1.get(Calendar.HOUR)+"😊;
System.out.print(ca1.get(Calendar.MINUTE)+"😊;
System.out.print(ca1.get(Calendar.SECOND));
}
}
运行结果:

4、分别利用ArrayList类、LinkedList类、Vector类创建集合,并实现相关用法。

5、谈一谈学习体会。
老师一次上课讲的内容有点多,上课的节奏有点跟不上,课后的作业有很多不会写,要去看书和看同学们的作业,看同学们编写的程序才能完成作业。学习的内容掌握不牢,还要在课余的时间多练习编写程序和多看书。

posted @ 2019-05-31 09:05  海诺音  阅读(159)  评论(0编辑  收藏  举报