Need assistance converting this to lambda in Java. Don’t reallyunderstand the syntax for lambda to well. Here is the snippet ofcode I need to convert.
ArrayList celebrityKittens = new ArrayList<>();
for(Celebrity c : celebrities.values()) {
for(Pet p: c.getPets()) {
if(p instanceof Cat && isKitten((Cat) p)) {
celebrityKittens.add((Cat) p);
System.out.println(p.toString());
}
}
}
Pet is an public List<Pet> pets = newArrayList<Pet>();
get Pets just returns the list of pets.
isKitten is written as:
private static boolean isKitten(Cat c)
{
if(c.getAgeInMonths() < 6)
{
return true;
}
return false;
}
{
Expert Answer
An answer will be send to you shortly. . . . .