Given: ArrayList a = new ArrayList(); containing the values {“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”} Which code will return 2?()
- A、 Collections. sort(a, a.reverse()); int result = Collections.binarySearch(a, “6”);
- B、 Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”);
- C、 Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);
- D、 Comparator c = Collections.reverseOrder(a); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);
- E、 Comparator c = new InverseComparator(new Comparator()); Collections.sort(a); int result = Collections.binarySearch(a, “6”,c);
正确答案:C
答案解析:有
微信扫一扫手机做题