Collections and generics

All the collection classes that are implemented use generics very heavily. As discussed in Chapter 2, Advanced Techniques and Reflection, generics provide the type of object that a collection contains. Every attempt to add another type of element generates a static analysis warning. Generics in collections have the following advantages:

  • They help avoid class cast errors at runtime since we get the warnings during the static analysis time
  • They make the code cleaner, as there is no need to use casting operators and conditions to check types
  • They add to the runtime benefit only because the execution is done in the production mode. The code that is compiled to JavaScript does not check types and generics
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.129.90