List<Integer> cats = goodsList.stream() .flatMap(c-> Stream.of(Collections.singleList(c.getFirstCategoryID()),c.getSecondCategoryIDList())).flatMap(stream -> stream.flatMap(Collection::stream)) .collect(Collectors.toList());
@ankitkpd