I have line like this↓ to get exact elements from list, but i want to add it multiple time using some kind of array like "for" with counter
list.stream().filter(x -> x.getUserID() == user.getUserID()).collect(Collectors.toList());
list.stream().map(o -> new Object[] { (Object) o }).collect(Collectors.toList();
I've had similar code but i dont want to use double for:
List<Object[]> tmp = new ArrayList<Object[]>();
for (Iterator<?> iterator = tests.getTestData().iterator(); iterator.hasNext();) {
Object objects = iterator.next();
//should have condition like id=id
for (int i = 0; i < t.getInvocationCount(it); i++) {
tmp.add(new Object[] { objects });
}
}
It is possible to multiple elements which fulfils condition using stream?
EDIT:
*tests.getTestData() -> returns List
**t.getInvocationCount -> returns int [t is not important cause it is generic]
i only need to multiple element in arry, in notice
FOR arry TO arry=END DO:
IF arry[i] IS statment=true DO:
FOR 0 TO outsideCounter_i DO:
tempArry.add(arry[i])
where * is arry
and ** is outsideCounter
I want to multiple element if statment is true using stream. If it is still unclear please add comment.
i read about nCopies and it is "cool" but can i use it inside stream?