So I've been working on some code and I have a custom class named word. From here I have a list of words (dupeWordList) and would like to remove all words from that list that have a value of null. Keep in mind, value is variable inside the word class. The word class contains the following stored values: Frequency (int) Value (String)
Is there anyway to remove all words that when you call word.getValue() it returns null? Surely there is a way to do this. If anything I could loop through the entire list and do this process.
Code:
List<Word> dupeWordList;
dupeWordList = new ArrayList<>(wordList);
dupeWordList.removeAll(Collections.singleton(null));
In java 8 you could do