SCJP題庫第197題

 
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.
 
Ans: B
 
解說:
LinkedList是一般串列,沒排序的功能
先進先出

Comments

Popular posts from this blog

Android-使用webview在V3版的Google地圖GPS定位