October 26, 2005
-
I hate Java
What kind of gay design is this?
public class A
{
String foo;
A()
{
foo = "A";
}
String getFoo()
{
return foo;
}
}public class B extends A
{
String foo;
B()
{
super();
foo = "B";
}
String getFoo()
{
return foo;
}
}// Now some code in main()...
public void main()
{
A bar = new B();
System.Console.Writeline(bar.getFoo());
}The above code compiles and executes but the resolution of getFoo() and foo
is simply stupid and annoying. I would have thought the designers are
smart enough to simply make re-declaration of fields illegal OR to
allow them to be dynamic instead of being static-only. Even worse is that fact that the static keyword is optional in this case (to mean whether the field belongs to the class or to the instances of the class).Thanks to Skrud for this quote (not in his exact words):
"When they made Java, they ignored 25 years of research in the field
of programming language design and just threw it out the window." - Dr.
Grogono- SwordAngel