开发者

Was the Inclusion of Generics in Java 5.0 Worthwhile? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, 开发者_如何转开发or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 12 years ago.

Aside from the added complexity, do you think that the inclusion of the Generics Mechanism in Java 5.0 was worthwhile?


Couldn't live without it! Do you want to go back to casting-from-Object in every container access and dealing with the resulting runtime-revealed type errors?! Basically destroys any rationale for using an allegedly statically typed language (and if I use a dynamically typed language, it's going to be Python or Javascript, not Java;-). Generics are a must for me.


Yes. Each and every cast in a Java program is a ClassCastException waiting to happen. Hence, using generics to avoid casting in the first place, means you have less opportunity for failure.

Perhaps you need to have programmed in a language with strong typing to appreciate that. I can recommend Haskell for this.


Yes, generics is usefull to check types in compilation time

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜