I have a Object with multiple properties and I want to add multiple properties to same list
I was able to add one property couldn't find a way to add other property.
Can we do that if yes how ?
List<MyObject> myObject = new ArrayList<>();
I have some values in the object here
List<Long> Ids = myObject .stream().map(MyObject::getJobId).collect(Collectors.toList());
here I want to add one more property from same MyObject object getTestId to the list is there a way that I can add with in the same above statement ?
List<Long> Ids=myObject.stream().flatMap(o -> Stream.of(o.getJobId(), o.getTestId())) .collect(Collectors.toList());