How would you "compress" a list?
java, list, performance
Solution
Most efficient I know of, in terms of code efficiency, is
list.removeAll( Collections.singleton(null) );
Problem
For instance say I have a list with the following values ``` {"A", null, null, "B", null, "C", null, "D", "E", null} ``` What would be the most efficient way to compress that to ``` {"A", "B", "C", "D", "E"} ``` Is there a way to do this quickly and efficiently without creating a new list altogether. It would also be fine if the compressed list looked like ``` {"A", "B", "C", "D", "E", null, null, null, null, null} ```