I don't think ArrayList was taught before, how to use it and solve this problem?
package com.codegym.task.task06.task0614;
import java.util.ArrayList;
/*
Static cats
1. In the Cat class, add the public static ArrayList<Cat> variable cats.
2. Each time a new cat (new Cat object) is created,
let it be added to the variable cats.
Create 10 Cat objects.
3. The printCats method should display all cats to the screen.
You need to use the variable cats.
*/
public class Cat {
//write your code here
public static ArrayList<Cat> cats;
public Cat() {
}
public static void main(String[] args) {
//write your code here
Cat[] cat = new Cat[10];
for(int i = 0; i < 10; i++) {
cat[i] = new Cat();
//cats<cat>++;
}
printCats();
}
public static void printCats() {
//write your code here
//System.out.println(cats);
}
}