Java 8 List.sort usage -


list class in java 8 has new method sort added it. please clarify when should prefer use opposed collections.sort(..) method?

there no functional difference because collections.sort(list) calls list.sort(null) , collections.sort(list, comparator) calls list.sort(comparator).

so it's matter of style - when providing own comparator, calling sort on list more natural , readable using external static method.

however if want sort list in natural order, collections.sort(list) maybe clearer list.sort(null).


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -