Practical usage of wildcard generics in Java -


Recently there was an examination on Java, and there was a wide section about wildcard genetics in Java. However, little has been said about their use in practice. When should we use them? See a general use:

  check for zero (archive & lt;? Extension in animal list) {// something}   

What the documentation says is, it does not allow adding any element to the archive list. So originally a collection of wildcards can be done for read-only. Is this their use only? Is there any practical need for this? For the past four years I have participated in many programming projects in Java, but I have not seen any project that will use such a facility as a wildcard.

So, from a practical perspective, is there a situation when wildcard generics are inevitable and necessary?

So, it is practical to see, is there a situation where the wildcard generics Are indispensable and necessary?

I do not think that they are 'indispensable and necessary' because the Java compiler removes them in any way. However, while using them, you get the benefit of a strict type of investigation during compile-time and you avoid type casting. Which way do you want to cast? :)



Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

java - Reaching JTextField in a DocumentListener -

c# - Add Image in a stackpanel based on textbox input -