In Java, why the compilation fails if we use reference variable of type Object?
Posted on 2011-02-19
public class HorseTest
public static void main(String  args)
public String name;
public Horse (String s)
name = s;
Object obj = new Horse("Zippo");
Why compilation error occurs in this line "Object obj = new Horse("Zippo");"? I already know if I use Horse obj = new Horse("Zippo"), then it will be fixed. I just want clear explanation why using reference variable of type Object will cause problems?
Thanks in Advance :)