I want to move some special object in the list to the bottom of it. I tried to used below code to implement it but it shows last assignment is never been used... I have walkaround but I really want to know why my code is wrong? After the method proceed the list I passed in, it still the old sequence. No impact...
private void moveNullBrokerToEnd(List<Broker> brokers) {
if (brokers != null) {
List<Broker> nullTypeBrokers = new ArrayList<>();
List<Broker> commonBrokers = new ArrayList<>();
for (Broker broker : brokers) {
if (broker.getMemberType()==null) {
nullTypeBrokers.add(broker);
} else {
commonBrokers.add(broker);
}
}
brokers = ListUtils.union(commonBrokers, nullTypeBrokers);
}
}