정리 블로그
https://beomseok95.tistory.com/218
https://dpdpwl.tistory.com/81
public class ScratchPad {
public static void main(String[] args) {
List<Artist> artistList = new ArrayList<>();
Artist artist1 = new Artist("얼수",10);
Artist artist2 = new Artist("ims",20);
Artist artist3 = new Artist("철수",30);
Artist artist4 = new Artist("짱구",40);
Artist artist5 = new Artist("짱아",50);
artistList.add(artist1);
artistList.add(artist2);
artistList.add(artist3);
artistList.add(artist4);
artistList.add(artist5);
List<Artist> newArtist = artistList.stream().filter(item->item.view>=30).collect(Collectors.toList());
for(Artist a : newArtist){
System.out.println(a.name);
}
}
}
class Artist{
String name;
Integer view;
Artist(String name,Integer view){
this.name=name;
this.view=view;
}
}