Given the code fragment:



What is the result?

A.

{1007 = A, 1002 = C, 1001 = B, 1003 = B}

B.

{1001 = B, 1002 = C, 1003 = B, 1007 = A}

C.

{1002 = C, 1003 = B, 1007 = A}

D.

{1007 = A, 1001 = B, 1003 = B, 1002 = C}

題解

TreeMap繼承SortedMap,會自動排序元素的key。所以這題答案是選項B。