I have a problem where I want to have two Objects of the same Class. However, all of their variables are in synch somehow and I don't know how to fix this...
For example: this is the Class of the objects
public class Cat
{
public static int age;
public static String breed;
public static String Name;
public static String fur;
private Cat (String name)
{
age = 5;
breed = "Birman";
fur = "soft";
Name = name;
}
}
and this is where I want to create Objects of this Class:
public class test
{
static Cat Whisky;
static Cat Ghismo;
public static void main(String[] args)
{
Whisky.age = 10;
Ghismo.breed = "Maine Coon";
System.out.println(Whisky.age + " " + Whisky.breed);
System.out.println(Ghismo.age + " " + Ghismo.breed);
}
}
For some reason the output is this:
10 Maincoon
10 Maincoon
Why does it always give me the same values in the output and how can I fix this?