实验报告 5 java常用类(一).docVIP

  • 136
  • 0
  • 约5.59千字
  • 约 9页
  • 2020-08-04 发布于河北
  • 举报
西 安 邮 电 大 学 (计算机学院) 面向对象程序设计JAVA 课内实验报告 实验名称: Java类库和常用类(二) 专业名称: 班 级: 学生姓名: 学号(8位): 指导教师: 实验时间: PAGE PAGE 4 实验目的及实验环境 实验目的: 1理解类库的概念,掌握分析、应用类库中的类的方法。 2熟练掌握Math类的常用方法。熟悉Random类的常用方法。 3理解String类的特性,熟练掌握String类的常用方法。 4能用Date类创建对象,熟练掌握Date类的常用方法。 5熟练掌握SimpleDateFormat解析日期和设置日期输出格式。 6学会查阅Java API在线参考文档和离线文档的方法。 实验环境:Eclipse for java 实验内容 1 基本内容(实验前请及时熟悉如下相关内容) 1)练习使用Math类的常用方法。 2)应用String类编程练习。 3)编写程序应用Random类生成随机数。 4)练习使用Date类的常用方法。 5)查阅Java API在线参考文档和下载Java API离线文档。 2 综合实验: 2.1 (Y. Daniel Liang英文版八版P296:8.3*) (Using the Date class) Write a program that creates a Date object, sets its elapsed time to 10000, 100000, 100000000, 1000000000, 10000000000, 100000000000, and displays the date and time using the toString() method, respectively. 2.2(Y. Daniel Liang英文版八版P296:8.4*) (Using the Random class) Write a program that creates a Random object with seed 1000 and displays the first 50 random integers between 0 and 100 using the nextInt(100) method. 2.3 (Y. Daniel Liang英文版八版P296:8.5*) (Using the GregorianCalendar class) Java API has the GregorianCalendar class in the java.util package that can be used to obtain the year, month, and day of a date. The no-arg constructor constructs an instance for the current date, and the methods get(GregorianCalendar.YEAR), get(GregorianCalendar.MONTH), and get(GregorianCalendar.DAY_OF_MONTH) return the year, month, and day. Write a program to perform two tasks: ■ Display the current year, month, and day. ■ The GregorianCalendar class has the setTimeInMillis(long), which can be used to set a specified elapsed time since January 1, 1970. Set the value to 1234567898765L and display the year, month, and day. 2.4(Y. Daniel Liang英文版八版P337:9.11**) (Sorting characters in a string) Write a method that returns a sorted strin

文档评论(0)

1亿VIP精品文档

相关文档