What is new in Java 8

1. There are default methods and static methods in interfaces in Java 8.
2. Lamdas

 Collections.sort(list, (o1, o2) -> o1.getTime() - o2.getTime());

Pre-Java8


 Collections.sort(list, new Comparator<Message>() {
        @Override
        public int compare(Message o1, Message o2) {
            return o1.getTime() - o2.getTime();
        }
    }); 

Comments

Popular posts from this blog

Can I name a method with the same name of the class in Java?

Quicksort Java implementation