Given the code fragment:
What is the result?
Given the code fragment:
What is the result?
The code uses List.of to create the list, which results in an immutable list. Attempting to sort this immutable list using clrs.sort(hueSrtr.thenComparing(valueSrtr)) will therefore throw an UnsupportedOperationException at runtime. Consequently, the correct answer is that an exception is thrown at runtime.
List.of creates unmodifiable list you can’t sort this list in a straightforward manner. clrs.sort() throws runtime exception : java.lang.UnsupportedOperationException in the case of reqular List the answer is A (sorting on the hue field and then on value)
C is correcrt List.of is an inmutable cannot add, sort or modified
C is correct, because List is inmutable, that is not add, remove, update elements or sort List
C is correct. List.of is a List inmmutable!