@@ -0,0 +1,648 @@
+package com.insightfullogic.java8.answers.chapter4;%0D%0A%0D%0Aimport java.util.List;%0D%0Aimport java.util.Optional;%0D%0A%0D%0Aimport com.insightfullogic.java8.examples.chapter1.Artist;%0D%0A%0D%0Apublic class ArtistsFixed %7B%0D%0A%0D%0A%09private List%3CArtist%3E artists;%0D%0A%0D%0A%09public ArtistsFixed(List%3CArtist%3E artists) %7B%0D%0A%09%09this.artists = artists;%0D%0A%09%7D%0D%0A%0D%0A%09public Optional%3CArtist%3E getArtist(int index) %7B%0D%0A%09%09if (index %3C 0 %7C%7C index %3E= artists.size()) %7B%0D%0A%09%09%09return Optional.empty();%0D%0A%09%09%7D%0D%0A%09%09return Optional.of(artists.get(index));%0D%0A%09%7D%0D%0A%0D%0A%09public String getArtistName(int index) %7B%0D%0A%09%09Optional%3CArtist%3E artist = getArtist(index);%0D%0A%09%09return artist.map(Artist::getName).orElse(%22unknown%22);%0D%0A%09%7D%0D%0A%7D%0D%0A

add ArtistsFixed class for chapter4