list - Remove all Elements With a Custom Null Value Java -
so i've been working on code , have custom class named word. here have list of words (dupewordlist) , remove words list have value of null. keep in mind, value variable inside word class. word class contains following stored values: frequency (int) value (string)
is there anyway remove words when call word.getvalue() returns null? surely there way this. if loop through entire list , process.
code:
list<word> dupewordlist; dupewordlist = new arraylist<>(wordlist); dupewordlist.removeall(collections.singleton(null));
in java 8 do
dupewordlist.removeif(e -> e.getvalue() == null)
Comments
Post a Comment