public static <E> List<E> getCommonsElements(List<E> list) {
return list.stream() // list 對應的 Stream
.collect(Collectors.toMap(e -> e, e -> 1, (a, b) -> a + b)) // 獲得元素出現頻率的 Map,鍵為元素,值為元素出現的次數
.entrySet().stream() // 所有 entry 對應的 Stream
.filter(entry -> entry.getValue() > 1) // 過濾出元素出現次數大於 1 的 entry
.map(entry -> entry.getKey()) // 獲得 entry 的鍵(重復元素)對應的 Stream
.collect(Collectors.toList()); // 轉化為 List
}