在最初没有理解和熟悉编写类时,能够说是一脸懵逼,“这些setXXXX()
,和getXXXX()
究竟是干什么的,return
是返回,那返回和输出的区别是什么,private
以前也从未见过。如何去解决呢?看例题、敲例题,当本身作完以后,研究输出结果,对照程序自己,就能理解其含义了。
这些程序比以前的要长得多,但例题好歹也是通常的JAVA语言,都能看懂。html
问题1:PP4.7,找不到对象,如图,java
问题1解决方案:输入String类参数时,应加双引号""
!git
问题2:例题4.1运行不了(找不到或没法加载主类 Die),如图,程序员
package week4
打包,在其前加上//
变为注释无效化便可。问题3:PP7.3编译错误*1,如图,编程
javac -Xlint:unchecked XXX
进行检查,发现建立名为Student的ArrayList时,没有肯定保存对象的数据类型致使错误,加入后建立:ArrayList<student> Student = new ArrayList<student>()
,问题解决。问题4:PP7.3运行错误*1,如图,数据结构
问题4解决方案:检查命令行提供的信息找到错误出处,发现关键函数
public float average() {学习
int i = 0; Sum = 0; while (i <= ScoreList.size()){ Sum += ScoreList.get(i); i += 1; } sum = Sum; AverageScore = sum / StudengtList.size(); return AverageScore;
循环语句中i <= ScoreList.size()
出了问题(i不能等于size,而是size-1),致使Sum += ......
没法正常进行。改成i < ScoreList.size()
后问题解决。测试
(statistics.sh脚本的运行结果截图)ui
错题1: The behavior of an object is defined by the object's
正确答案:method
错误缘由:想固然认为全部因素都影响着对象的行为,然而全部行为确实归根结底都是方法决定的;
错题2:All Java classes must contain a main method which is the first method executed when the Java class is called upon.
正确答案:false
缘由:只有驱动类才须要main方法,只有驱动类才须要main方法,只有驱动类才须要main方法。
错题3:Every class definition must include a constructor.
正确答案:false
缘由:能够没有构造函数。
错题4:During program development, software requirements specify
正确答案:what the task is that the program must perform
缘由:纯粹的英语很差,没读懂题意,这道题根本就是一道英语题。
错题5:The goal of testing is to
正确答案:find logical and run-time errors
缘由: 测试的目的是找到逻辑错误和运行错误,而语法错误是不须要从这里找的,由于javac的时候就发现了。
错题6:Interface classes cannot be extended but classes that implement interfaces can be extended.
正确答案:false
缘由:彻底能够扩展。。。。
错题7:All objects implement Comparable.
正确答案:false
缘由:只有实现了接口(定义compareTo方法),才能comparable。
代码行数(新增/累积) | 博客量(新增/累积) | 学习时间(新增/累积) | 重要成长 | |
---|---|---|---|---|
目标 | 5000行 | 30篇 | 400小时 | |
第一周 | 195/195 | 1/4 | 20/20 | 对代码产生了很大兴趣 |
第二周 | 309/504 | 1/5 | 20/40 | 打字速度明显提高 |
第三周 | 311/815 | 2/7 | 25/65 | 无 |
第四周 | 474/1289 | 1/8 | 30/95 | 抗...抗压能力增强? |