I simply don't understand how this can be wrong... Anyone got any ideas?

public class Cat {

public Cat() {
}
//add your code here
public static ArrayList<Cat> cats = new ArrayList<Cat>();

public static void main(String[] args) {
    //Create 10 Cats here
    for (int i = 0; i < 10; i++)
    {
        Cat cat = new Cat();
        cats.add(cat);
    }
    printCats();
}

public static void printCats() {
    //Add your code for step 3 code here
    for (int i = 0; i < 10; i++){
        System.out.println(cats.get(i));
    }

}

}

asked 04 Dec, 18:03

MrZloyHomyak's gravatar image

MrZloyHomyak
111
accept rate: 0%


Problem solved. Don't how this is different but IDEA said it's okay when I swaped output with for to foreach scheme.

link

answered 04 Dec, 18:24

MrZloyHomyak's gravatar image

MrZloyHomyak
111
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×11
×10
×4

Asked: 04 Dec, 18:03

Seen: 33 times

Last updated: 04 Dec, 18:24