> For the complete documentation index, see [llms.txt](https://bernardo.gitbook.io/development-docs-java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bernardo.gitbook.io/development-docs-java/functional/streams/data-structure-transformations.md).

# Data Structure Transformations

## To String

```java
final String employees;

employees = empStream.map(Employee::getName).collect(Collectors.joining(", "));
```

## To Map

```java
final Map<Long, Employee> employees;

employees = empStream.collect(Collectors.toMap(Employee::getId, Function.identity()));
```

## To Map of Lists

```java
final Map<String, List<Employee>> employees;

employees = empStream.collect(Collectors.groupingBy(Employee::getCity));
```
