I call printCats() repeatedly and it actually works as requested: printing each object in cats on a new line.
I suppose I just need a little confirmation that it is only my printCats() method that is failing?
package com.codegym.task.task06.task0614;
import java.util.ArrayList;
/*
Static cats
*/
public class Cat {
//write your code here
public static ArrayList<Cat> cats;
public Cat(){}
public String name;
public static void main(String[] args) {
//write your code here
ArrayList<Cat> cats = new ArrayList<Cat>();
for (int n=0; n<10; n++){
Cat cat = new Cat();
cats.add(cat);
//name = String.valueOf(cats.get(cats.size()-1));
printCats(String.valueOf(cats.get(cats.size()-1)));
}
//Cat cat1 = new Cat();
}
public static void printCats(String name) {
//write your code here
//this method needs to print all cats on the screen
//at the end in one go.
//each on a new line
/*cats.forEach(cats ->{
System.out.println(cats); }); */
//for(Cat cat:cats )
System.out.println(name);
}
}