I have a List<List<Object>> type data. I need to add the same value in the List list.
I tried the following but it doesn't work as its type is List<Boolean>.
List<List<Object>> data = ...;
data.stream().map(v -> v.add("test")).collect(Collectors.toList());
How can I get in same type List<List<Object>> ?
I have the following data:
"data": [
[
5,
"Johnny",
"Lollobrigida"
],
[
6,
"Bette",
"Nicholson"
],
[
7,
"Grace",
"Mostel"
],
[
8,
"Matthew",
"Johansson"
]
]
I want to change it to:
"data": [
[
5,
"Johnny",
"Lollobrigida",
"test"
],
[
6,
"Bette",
"Nicholson",
"test"
],
[
7,
"Grace",
"Mostel" ,
"test"
],
[
8,
"Matthew",
"Johansson",
"test"
]
]
list.add?data.forEach(l -> l.add("test"))?map.forEach.peekfor that; that’s nowhere better thanmap. Neither is meant to be used to manipulate the source of the Stream.