您的位置:首页 > 编程语言 > Java开发

20155321 2016-2017-2 《Java程序设计》第七周学习总结

2017-04-09 15:52 555 查看

20155321 2016-2017-2 《Java程序设计》第七周学习总结

教材学习内容总结

Date/DateFormat

Date是日期类,可以精确到毫秒。

构造方法

Date()

Date(long time)

成员方法

getTime()

setTime(long time)

日期和毫秒值的相互转换

DateFormat针对日期进行格式化和针对字符串进行解析的类,但是是抽象类,所以使用其子类SimpleDateFormat

SimpleDateFormat(String pattern) 给定模式yyyy-MM-dd HH:mm:ss

日期和字符串的转换

Date -- String:format()

String -- Date:parse()

Calendar

日历类

封装了所有的日历字段值,通过统一的方法根据传入不同的日历字段可以获取值

得到一个日历对象

Calendar rightNow = Calendar.getInstance();

本质返回的是子类对象

成员方法

根据日历字段得到对应的值

根据日历字段和一个正负数确定是添加还是减去对应日历字段的值

设置日历对象的年月日

教材学习中的问题和解决过程

问题1:课本P430代码在IDEA上执行结果见下图,与书本上不一致,书本上的应该是不对的



其次对于此代码上显示的LONG与SHORT不太理解是什么意思?



问题1解决方案:通过查API得知这些都是不同长度的常数,是给定的格式设置样式



问题2:课本P435提到了clone()、before()、after()方法,不是很清楚这几个方法是什么意思

问题2解决方案:通过查询API得知clone()方法其实是复写了Object父类方法,其结果是返回了该对象的一个副本





代码调试中的问题和解决过程

问题1:课本P436程序TimeZoneDemo执行结果中时间ID一栏是Asia/Shanghai,不应该是Asia/Beijing吗?



问题1解决方案:通过网上的资料显示,Java所支持的所有时区里没有Asia/Beijing,对于中国大陆时区的而言,显示的都是Asia/Shanghai

代码托管



上周考试错题总结

错题1:下面哪条命令可以把 f1.txt 复制为 f2.txt ?

A .cp f1.txt f2.txt

B .copy f1.txt f2.txt

C .cat f1.txt > f2.tx

D .cp f1.txt | f2.tx

E .copy f1.txt | f2.tx

原因:我选择了AB。主要是对输出重定向不太了解

理解情况:正确答案应为AC,copy是Windows下的命令。cat f1.txt > f2.tx通过输出重定向实现了复制

错题2:Linux中,使用()命令可以更改一个文件的权限。

A .attrib

B .change

C .chmod

D .file

原因:望文生义,因为更改就是用change。。

理解情况:attrib是Windows下的命令,没change这个命令,file是用来查看文件类型的

错题3:下面代码中共有()个线程?

```

public class ThreadTest {

public static void main(String args[]){

MyThread myThread =new MyThread();

Thread t1=new Thread(myThread);

Thread t2=new Thread(myThread);

t1.start();

t2.start();

}

}

class MyThread extends Thread {

...

}

A .1   B .2  C .3  D .4
- 原因:忘记了还有主线程
- 理解情况:2个自定义的线程和1个主线程,共三个

- 错题4:Assuming / is the root directory, which of the following are true statements? (Choose all that apply.)

A ./home/parrot is an absolute path.

B ./home/parrot is a directory.

C ./home/parrot is a relative path.

D .The path pointed to from a File object must exist.

E .The parent of the path pointed to by a File object must exist.
- 原因:没看懂题目
- 理解情况:Paths that begin with the root directory are absolute paths, so A is correct and C is incorrect. B is incorrect because the path could be a file or directory within the file system. A File object may refer to a path that does not exist within the file system, so D and E are incorrect.

- 错题5:What is the result of executing the following code? (Choose all that apply.)

String line;

Console c = System.console();

Writer w = c.writer();

if ((line = c.readLine()) != null)

w.append(line);

w.flush();

```

A .The code runs without error but prints nothing.

B .The code prints what was entered by the user.

C .An ArrayIndexOutOfBoundsException might be thrown.

D .A NullPointerException might be thrown.

E .An IOException might be thrown.

F .The code does not compile.

理解情况:This is correct code for reading a line from the console and writing it back out to the console, making option B correct. Options D and E are also correct. If no con- sole is available, a NullPointerException is thrown. The append() method throws anIOException.

错题6:What are some reasons to use a character stream, such as Reader/Writer, over a byte stream, such as InputStream/OutputStream? (Choose all that apply.)

A .More convenient code syntax when working with String data

B .Improved performance

C .Automatic character encoding

D .Built-in serialization and deserialization

E .Character streams are high-level streams

F .Multi-threading support

理解情况:Character stream classes often include built-in convenience methods for working withString data, so A is correct. They also handle character encoding automatically, so C is also correct. The rest of the statements are irrelevant or incorrect and are not properties of all character streams.

结对及互评

20155330

点评过的同学博客和代码

本周结对学习情况

20155330

结对学习内容

学习了本周实验的相关内容及知识点

学习了第十三章的内容

上周博客互评情况

20155230

20155215

20155306

20155239

20145202

其他(感悟、思考等,可选)

Java后续学习的知识使用起来还是比较生疏,有的时候对某些以为自己懂的概念还是比较模糊,所以之后对于Java的学习,还是需要多实践,在实践中总结经验,提升能力。

学习进度条

代码行数(新增/累积)博客量(新增/累积)学习时间(新增/累积)重要成长
目标5000行30篇400小时
第一周1/20/20对IDEA、git、JDK、JVM有了更多的了解,面对学习过程中遇到的困难学会自己主动地寻找办法去解决
第二周1/218/38掌握了Java中的基本运算符和基本语句
第三周1/322/60对面向对象、封装、构造函数等重要知识点有了初步理解,学会自主学习,遇到困难的时候从多方面寻找资料以求答案
第四周1/422/60对继承和多态了一定程度的理解,并学会使用多态来提高代码的复用性
第五周706/26391/525/85对异常以及集合框架的学习
第六周735/31941/628/113对IO流,多线程以及并行API的学习
第七周428/34741/718/131对Date的学习
尝试一下记录「计划学习时间」和「实际学习时间」,到期末看看能不能改进自己的计划能力。这个工作学习中很重要,也很有用。

耗时估计的公式

:Y=X+X/N ,Y=X-X/N,训练次数多了,X、Y就接近了。

参考:软件工程软件的估计为什么这么难软件工程 估计方法

计划学习时间:15小时

实际学习时间:18小时

改进情况:还是要扎实学习之前的知识,避免对后续学习产生过多不良影响

(有空多看看现代软件工程 课件

软件工程师能力自我评价表)

参考资料

Java学习笔记(第8版)

《Java学习笔记(第8版)》学习指导
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: