Given:
11. public static Collection get(){
12. Collection sorted = new LinkedList();
13. sorted.add("B"); sorted.add("C"); sorted.add("A");
14. return sorted;
15. }
16. public static void main(String[] args){
17. for(Object obj : get()){
18. System.out.print(obj + ", ");
19. }
20. }
What is the result?
A. A, B, C,
B. B, C, A,
C. Compilation fails.
D. The code runs with no output
E. An exception is thrown at runtime.
答案:B
參考:12-4-5 List集合
-----------------------
sorted 是LinkList... 直接加 B C A 並回傳
沒有留言:
張貼留言