w*********n 发帖数: 439 | 1 double[] times = {3.56, 3.9, 2.6, 4.5, 2.4, 5.2};
double[] bestTimes = new double[4];
Arrays.sort(times);
bestTimes = Arrays.copyOfRange(times, 1, 4);
(Refer to code example 11-1.) What is the length of the bestTimes array?
Answer
a.3
b.6
c.5
d. 4 | h**k 发帖数: 662 | 2 这个难道不是看api嘛
to index is exclusive
【在 w*********n 的大作中提到】 : double[] times = {3.56, 3.9, 2.6, 4.5, 2.4, 5.2}; : double[] bestTimes = new double[4]; : Arrays.sort(times); : bestTimes = Arrays.copyOfRange(times, 1, 4); : (Refer to code example 11-1.) What is the length of the bestTimes array? : Answer : a.3 : b.6 : c.5 : d. 4
| z****e 发帖数: 54598 | | w*********n 发帖数: 439 | 4 多谢回复。请问我的理解对吗?
1。double[] bestTimes = new double[4];
//说明 bestTime 里面有4个元素是把?
2。Arrays.sort(times);
//把time里面的元素排序对吗?
3。bestTimes = Arrays.copyOfRange(times, 1, 4);
//把bestTimes元素1取到元素4复制给times对吗?
这样从元素1到元素4不是4个元素吗怎么是3呢?
【在 w*********n 的大作中提到】 : double[] times = {3.56, 3.9, 2.6, 4.5, 2.4, 5.2}; : double[] bestTimes = new double[4]; : Arrays.sort(times); : bestTimes = Arrays.copyOfRange(times, 1, 4); : (Refer to code example 11-1.) What is the length of the bestTimes array? : Answer : a.3 : b.6 : c.5 : d. 4
| z****e 发帖数: 54598 | 5 你找本java教材好好看看吧
从头看到尾,你问的问题java教材上都有
学习语言不是考试,背题没有太多意义
就算给了你答案,换个题目你还是不会做 | r********r 发帖数: 208 | 6 double[] bestTimes = new double[4];
...
bestTimes = Arrays.copyOfRange(times, 1, 4);
The above 2 bestTimes's refer to 2 different arrays, and the memory referred
by the former will be GCed sooner or later.
Correct me if I am wrong. | P**l 发帖数: 3722 | | n******t 发帖数: 28 | 8 这个跟GC 没关系.
想想bestTimes 里存的是什么东西, '='是一个赋值操作. |
|