public class Test {
public static void main(String[] args){
Hero2 hero2 = new Hero2();
Hero4 hero4 = new Hero4();
Hero6 hero6 = new Hero6();
Team team = new Team(hero2,hero4,hero6);
System.out.println(team.hero1 instanceof Hero1);
}
}
class Team {
Hero hero1;
Hero hero2;
Hero hero3;
public Team(Hero hero1, Hero hero2, Hero hero3) {
this.hero1 = hero1;
this.hero2 = hero2;
this.hero3 = hero3;
}
}
takeIf { it.isNotEmpty() }
?