Collection Sort Lamba in Java

Java 8 이전에서 객체나 Map 같은 것을 정렬하기 위해서는 Collections 을 사용해야만 했다. 예를들어 다음과 같은 소스다.

하지만 Java 8 에 도임된 람다(Lambda) 를 사용할 경우에 이를 간단하게 해결할 수 있다.

더 나가 람다는 타입을 정의하지 않아도 된다. 컴파일러가 타입을 추론(Inferring) 하게 된다. 따라서 다음과 같이 간단하게 쓸 수 있다.

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">