Here is my code which has for Each loop but each time it is iterating and giving the last iteration result. EX: if there are 2 iterations. Both the iteration is giving the last iteration result.
private List<someData> getsomeDetails(
BusDetail bus)
{
List<someData> someDataList = new ArrayList<>();
SSsome SSsome = new SSsome();
bus.getBUDetail().get(0).getBUDetail().getBUList().forEach(bu -> {
SSsome.setNbr(bu.getNumber());
SSsome.setCountryCode(bu.getState());
SSsome.setStatus("PROCESSING");
someDataList.add(SSsome);
});
return someDataList;
}
Can someone please help at the earliest.
Thanks in advance.