Java Stream
find Index
IntStream.range(0, users.size())
.filter(userInd-> users.get(userInd).getName().equals(username))
.findFirst()
.getAsInt();
collect 指定 型別
List<String> fields=Arrays.asList("foo", "bar", "baz", "foo");
CopyOnWriteArrayList<String> l =
fields.stream()
.distinct()
.collect(Collectors.toCollection(CopyOnWriteArrayList::new));
```
## collection to map
```java=
var map= l.stream().collect(Collectors.toMap(e -> e.positionSide, e-> e));
groupingBy to List
```java=
Map<BlogPostType, List
進階
```java=
List<CacheKBar> list= cacheKBarDao.findByExchangeAndPair(exPair.exchange,exPair.pair);
return list.stream()
.collect(Collectors.groupingBy(
CacheKBar::getSer,
Collectors.mapping(CacheKBar::load, Collectors.toList())
));