About Questions 1830 and 1875
Posted: Fri Dec 16, 2016 8:46 pm
Hi All,
I'm struggling to understand how these two snippets of code are different and why one fails to compile while the other one throws and exception at RT. Could somebody explain please?
#1
#2
Thanks!
I'm struggling to understand how these two snippets of code are different and why one fails to compile while the other one throws and exception at RT. Could somebody explain please?
#1
Code: Select all
List<Book> books = getBooksByAuthor("Ludlum");
Collections.sort(books, (b1, b2)->b1.getTitle().compareTo(b2.getTitle()));//1
Collections.sort(books); //2
Code: Select all
List<Book> books = getBooksByAuthor("Ludlum"); books.stream().sorted().forEach(b->System.out.println(b.getIsbn())); //1