Home > Java > javaTutorial > How to convert java Map

How to convert java Map

WBOY
Release: 2023-04-18 11:34:02
forward
1057 people have browsed it

Explanation

1. The map() method is an intermediate operation. It returns a stream including the results of applying the given function to each element in the stream.

2. The intermediate operation Map can help us process each element in the List.

Example

Through map we convert each string to uppercase.

stringCollection
    .stream()
    .map(String::toUpperCase)
    .sorted((a, b) -> b.compareTo(a))
    .forEach(System.out::println);
 
// "DDD2", "DDD1", "CCC", "BBB3", "BBB2", "AAA2", "AAA1"
Copy after login

What collection classes are there in Java?

Collections in Java are mainly divided into four categories:

1. List: ordered, repeatable;

2. Queue: ordered and repeatable;

3. Set: non-repeatable;

4. Map: unordered, with unique keys and non-unique values.

The above is the detailed content of How to convert java Map. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template