Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public Book longestTitleForEach(Book book) {
  2. if (nbBook == 0) { //Si nombre de book = 0 alors il n'y a pas de book
  3. return null;
  4. }
  5. Book longuestTitle = books.get(0); //on stock le livre qui a pour l'instant la plus grande taille
  6. int longuestSize = longuestTitle.getTitle().length();
  7.  
  8. books.forEach((i) -> {
  9.  
  10. Book currentBook = i;
  11. int currentSize = currentBook.getTitle().length();
  12. if (currentSize > longuestSize) {
  13. longuestTitle = currentBook;
  14. longuestSize = currentSize;
  15. }
  16. });
  17. return longuestTitle;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement