I have the data as:
List<Object[]> result=fromDB();
How can I write the code below with Streams in Java 8?
Map<String,BigInteger> map= new HashMap<>();
for (Object[] obj : result) {
map.put((String)obj[0], (BigInteger)obj[1])
}
Map<String, BigInteger> map =
fromDB().stream()
.collect(Collectors.toMap(
o -> (String) o[0],
o -> (BigInteger) o[1],
(b1, b2) -> b2
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With