Code:
public class Dog{
static int age;
static String name;
static String breed;
public Dog(String name,int age,String breed){
this.name=name;
this.age=age;
this.breed=breed;
}
public Dog(String name,int age){
this(name,age,"greed");
}
public static void main(String args[]){
Dog high=new Dog("luffy",19,"pomerian");
Dog low=new Dog("gold",32,"german shepherd");
System.out.println(low.name+" "+low.age+" "+low.breed);
System.out.println(high.name+" "+high.age+" "+high.breed);
}
}
Output:
gold 32 german shepherd
gold 32 german shepherd
Though i'm creating two object instances, only the fields of one of them are printed.Where does the bug lie?