I want to use streams to Uppercase Book name in my List
List<Book> list = new ArrayList<Book>();
list.add(new Book("1", "Java", 10));
list.add(new Book("2", "Spring", 20));
list.add(new Book("3", "Webservices", 30));
I want to convert case of my book name. My current approach is giving me List<String> instead of List<Book> --------- [JAVA, SPRING, WEBSERVICES]
package java8;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;;
public class StreamTest {
public static void main(String s[]) {
List<Book> list = new ArrayList<Book>();
list.add(new Book("1", "Java", 10));
list.add(new Book("2", "Spring", 20));
list.add(new Book("3", "Webservices", 30));
List<String> updateList = list.stream().map(str2 -> str2.getName().toUpperCase()).collect(Collectors.toList());
System.out.println("--------- "+updateList);
}
}