Originally posted by Joey Chen:
Thanks for the response.
However, I don't understand why there needs to be a "Foo" in "Foo d" to identify what type of reference d is referring to if "new Foo()" already does that? It seems to me that the "Foo" in "Foo d" is redundant.
Why isn't it just d = new Foo(); ?
The type of d doesn't need to be Foo, it just needs to be able to hold a Foo object. The following is also valid
Java code:
Object d = new Foo();
Also remember that
d = new Foo();
as valid Java code for using a variable that has been declared earlier. That is, with your proposal you wouldn't be able to see whether this actually is a declaration of a new variable, or the usage of an already existing one.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus