0 votes
in JAVA by
How to use map to convert object into Uppercase in Java 8?

1 Answer

0 votes
by
/Older way to convert object to uppercase
		List<String> names = Arrays.asList("aa", "bb", "cc", "dd");

        List<String> uppercaseNames = new ArrayList<>();
        for (String name : names) {
            uppercaseNames.add(name.toUpperCase());
        }
       // In Java 8
        List<String> nameLst = names.stream().map(String::toUpperCase).collect(Collectors.toList());
        System.out.println(nameLst); //output- [AA, BB, CC, DD]
...