There is no provision for this post if above is the only thing it were to say. Google is there to help you find these references. I wanted to point out a minor advantage of using Generics in Java code. All the major advantages like catching the errors as soon as you make them is covered nicely in the above references. Here is that minor time-saver:
If you use raw collections (e.g. List and not List<String>), it is rather time-consuming to find what they contain.Of course, one could argue that one should check Javadocs for that. But in a state-of-the-art IDE like IDEA and a modularized build, you generally tend to look at the source and in deeply rooted call trees, it is not immediately clear instances of what type are added to a List. So, consider using generic types.
No comments:
Post a Comment