Returns a stream by applying the given function to each element.
Syntax
stream.map(mapper)Example
Enter values below to update the example in real time.
List→String→names→of→stream→map→toUpperCase→collect→Collectors→toList→System→out→println→ALICE→BOB→CAROL→List<String> names = List.of("alice", "bob", "carol");
List<String> upper = names.stream()
.map(String::toUpperCase)
.collect(Collectors.toList());
System.out.println(upper); // [ALICE, BOB, CAROL]