I have a arraylist of objects Box and i need to find all id of Boxes with more than one specific style. Example:
ArrayList<Box> boxes = new ArrayList<>();
Style s1 = new Style("black",160);
Style s2 = new Style("yellow", 150);
Style s3 = new Style("green", 150);
boxes.add(new Box(s1));//id 0
boxes.add(new Box(s2));
boxes.add(new Box(s2));
boxes.add(new Box(s3));//id 3
and need to find all boxes with style s2 and s3 for example (This styles can be n and they will be store in array). Result will be {1,2,3}. Is there a effective way to do that?
class Box{
private int id;
private Style style;
public Box(){}
//GETTERS AND SETTERS
}
class Style{
private String background;
private int width;
public Style(){}
//GETTERS AND SETTERS
}