1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { List<String> fruits = Arrays.asList( "apple", "kiwi fruit", "strawberry", "orange" ); var fruitsUpperCase = fruits.stream() .map(e -> e.toUpperCase()) .collect(Collectors.toList()); p(fruits); p(fruitsUpperCase); } public static <T> void p(T a) { System.out.println(a); } } |
1 2 |
[apple, kiwi fruit, strawberry, orange] [APPLE, KIWI FRUIT, STRAWBERRY, ORANGE] |