I really like the fact that Java is statically typed. When I use Perl or especially PHP or ColdFusion, the lack of real types annoys me after immersing myself in Java for the past four or five years. That said, I think that Charles Miller’s suggestion that Java infer types when it can is a good one. As long as something is defined as a particular type originally, I shouldn’t have to tell the compiler what type it is later on down the road when its type is perfectly clear in context. For example, if I’m assigning an element in a collection to the type
Foo, I shouldn’t need to cast the element to
Foo. If it can’t be a
Foo, I’m going to get a
ClassCastException at runtime, even with the cast in place. So what value does the cast bring to the table?