I have a three-color Array, Red, Blue and Green, with a while I add 10 random colors to an ArrayList. I need to find all the colors "Red", "Blue" and "Green" of the ArrayList, and then add all the "Red" colors found to an array where only "Red" colors will be stored, same with the other Strings. How do I do it? Thanks in advance.
public static void main(String[] args) {
String[] colores = {"Rojo","Azul","Verde"};
ArrayList<String> listaColores = new ArrayList<>();
int numeroColores = 0;
while(numeroColores < 10){
int random = (int)(Math.random() * 3);
String color = colores[random];
listaColores.add(color);
numeroColores++;
}