There is a working code about a program in which you should create differen Cat objects with name and color parameter and apply method to the objects.
The problem is that I get the method working for only the last cat
public class Cats {
public static String name;
public static String color;
public Cats(String firstname, String bodycolor)
{
name = firstname;
color = bodycolor;
}
public void SayMiau(){
System.out.printf("Cat %s which is %s in color said miauuuu!%n", name , color);
}
public static void main(String [] args) {
Cats Number[] = new Cats[6];
Number[0] = new Cats("Juja","orange");
Number[1] = new Cats("Kisa","mixed");
Number[2] = new Cats("Sasi","mixed");
Number[3] = new Cats("Mitio","black");
Number[4] = new Cats("Ricar","yellow");
for(int i = 0; i<5; i++)
Number[i].SayMiau();
}
}
Number.SayMiau() gives info only about Number[4].