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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -