20172332 2017-2018-2 《程序设计与数据结构》第六周学习总结
教材学习内容总结
学的有些晕的第八章数组
- 1.类似于一个列表的数组中所包含的元素被称为数组元素。
- 2.数组是对象,使用前必须声明数组。(声明时需要定义数据的类型。)
- 3.边界检查:数组的长度是不变的,若是超出会抛出ArrayIndexOutOfBoundsException异常。最容易产生的就是差1错误。(因为索引是从0开始)
- 4.数组的两种声明方式:①int[] grades; ②int grades[]; (第一种方式常用)
- 5.数组初始值表:只能在数组的第一次声明时使用,初始化实质上与声明基本类型变量的初始化概念相同。
- 6.整个数组可以作为参数传递给一个方法。一个数组元素也可以传递给方法。
- 7.数组也可以将对象引用作为元素保存。
- 8.给程序提供输入信息的方式命令行实参。(String[]参数(通常称为args))
- 9.可变长度参数表(每次调用方法时需要处理的数据量不同)(数据类型 ... 形参)
- 10.二维数组([][]第一个是行,第二个是列)
- 11多维数组:java并不能直接支持多维数组,多维数组表示为保存数组对象引用的数组,也就是把数组保存在数组中,从而形成多维数组。
教材学习中的问题和解决过程
代码调试中的问题和解决过程
- 问题1:算数组长度时用的
变量名.length
而不是变量名.length()
- 问题1解决方案:因为用的是属性而不是方法。
问题2:pp8.1输50超出长度了。

问题2解决方案:图一改为图二,长度差了1,就是所谓的差一问题。


问题3:结果把判断结束输入数字的最后一个0.2也算了一次次数。

问题3解决方案:图一改为图二


- 问题4:pp8.6题目都看不懂,一点都无从下手,错误多的都不知道怎么说。(悲伤(〒︿〒))
问题4解决方案:这题具体就看码云吧,因为从头到尾都是改过无数遍的,错误具体也没记住。

上周考试错题总结
1.Assume that count is 0, total is 20 and max is 1. The following statement will do which of the following? if (count != 0 && total / count > max) max = total / count;
- A . The condition short circuits and the assignment statement is not executed
- B . The condition short circuits and the assignment statement is executed without problem
- C . The condition does not short circuit causing a division by zero error
- D . The condition short circuits so that there is no division by zero error when evaluating the condition, but the assignment statement causes a division by zero error
- E . The condition will not compile because it uses improper syntax
- 答案:A ;我选的:D
- 分析:左边的条件是错误的,因此该条件语句直接是不执行的。又因为条件语句是错的,所以该条件语句下的赋值语句也不执行。
- 单词:1.short circuits:条件语句。2.assignment statement:赋值语句。3.division:分开。4.improper:不合适的。
2.When comparing any primitive type of variable, == should always be used to test to see if two values are equal.
3.If a switch statement is written that contains no break statements whatsoever,
- A . this is a syntax error and an appropriate error message will be generated
- B . each of the case clauses will be executed every time the switch statement is encountered
- C . this is equivalent to having the switch statement always take the default clause, if one is present
- D . this is not an error, but nothing within the switch statement ever will be executed
- E . none of the above
- 答案:E ;我选的:B
- 分析:写这样的switch语句是不寻常的,但它完全是合法的。它会一次执行每一条case语句。
- 单词:1.appropriate:适当的。2.**generated*:生成。3.encountered:冲突。4.equivalent:对等的。
4.How many times will the following loop iterate?
- int x = 10;
- do {
- System.out.println(x);
- x--;
- } while (x > 0);
- A . 0 times
- B . 1 times
- C . 9 times
- D . 10 times
- E . 11 times
- 答案:E ;我选的:D
- 分析:忘记了Do循环先不判断条件,不管满不满足条件,都会运行一次。Do循环是先运行才判断,while循环是先判断再运行
- 单词:1.loop:循环。2.iterate:迭代。
5.The following for-loop is an infinite loop.
- for (int j = 0; j < 1000; ) i++;
A . true
B . false
- 答案:A ; 我选的:B
- 分析:每次迭代的是i,与j无关所以一直是无限循环。
- 单词:1.infinite:无限。
点评模板:
- 博客中值得学习的或问题:
- 代码中值得学习的或问题:
点评过的同学博客和代码
其他(感悟、思考等,可选)
- 1.很明显!这个数组一章,看着貌似很简单,但是实际做起来题一点都不简单!
- 2.还是得多做点题,深入了解数组这个小妖精ヽ(#`Д′)?。
学习进度条
目标 |
5000行 |
30篇 |
400小时 |
|
第一周 |
182/182 |
1/1 |
10/10 |
|
第二周 |
458/640 |
1/2 |
15/25 |
|
第三周 |
469/1109 |
2/4 |
18/43 |
学会IDEA的使用和调试,学会jdb调试。 |
第四周 |
1536/2645 |
1/5 |
24/67 |
|
第五周 |
980/3625 |
1/6 |
25/92 |
|
第六周 |
870/4495 |
1/7 |
16/108 |
|
参考资料
20172332 2017-2018-2 《程序设计与数据结构》第六周学习总结
原文:https://www.cnblogs.com/yu757503836/p/8783042.html