0

I know that predicates are ment to specify which object of ArrayList has to be deleted. Instead of deleting I'd like to set to null those objects.

Like

arrayList.setIf(myPredicate,null); instead of arrayList.removeIf(myPredicate)

I have prepared so many predicates so I dont want to waste it.

  • You have to code it yourself. It doesn't exist. – Seelenvirtuose Feb 24 '17 at 18:14
  • 2
    Possible duplicate of [How to replace a value conditionally in a Collection, such as replaceIf(Predicate)?](http://stackoverflow.com/questions/35807818/how-to-replace-a-value-conditionally-in-a-collection-such-as-replaceifpredicat) – Calculator Feb 24 '17 at 18:18

1 Answers1

0

you have to write your own logic for that their is no such functionality to handle such scenario but still you can do some thing like this:

   yourList.stream().map(y -> {
     if (y.Something().equals("something"))
        return y;
        else
            return null;
    }).collect(toList());
Gurinder
  • 943
  • 2
  • 9
  • 19