I am looking for an optimized solution to remove keys null
with HashMap
. This HashMap is present inside ArrayList
. The following is an example.
public class Car {
String year;
String model;
Map<String,String> colors;
}
List<Car> listOfCars = new ArrayList<Car>();
An example color map might look like this:
{
red(1),
blue(2),
green(3),
black(4),
null(5)
}
I need a solution to iterate over listOfCars
, get a color map and remove from it null
. Trying to see other options in Java8 instead of using Iterator.
Thank!
source
share