12. import java.util.*;
13. public class Explorer3{
14. public static void main(String[] args){
15. TreeSet
16. TreeSet
17. for(int i=606; i<613; i++)
18. if(i%2 == 0) s.add(i);
19. subs = (TreeSet)s.subSet(608, true, 611, true);
20. subs.add(629);
21. System.out.println(s + " " + subs);
22. }
23. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. [608, 610, 612, 629] [608, 610]
D. [608, 610, 612, 629] [608, 610, 629]
E. [606, 608, 610, 612, 629] [608, 610]
F. [606, 608, 610, 612, 629] [608, 610, 629]
答案:B
參考:12-4-4 子集檢視
---------------------------------------------
19. 設定子集檢視為608到611(含608和611),
20. 要加入629, 已超出範圍
沒有留言:
張貼留言