Generics

Rule2: Prefer List Over Array:

Though the performance will be a bit degraded but you wound not have to see ClassNotFoundException at runtime.
Basically there are two difference btw array and List i,e List is invarient where as array is variant (subtype can be accommodated in supertype ) . secondly , List is eraseure i.e don’t checkor erases the type at runtime it does at compile timr only .
arrays are riefiable ,they pop up run time error i.e they let the program pass through compile time and point out errorrs at run time.
It is illegal(offical java convention,it will show error ) to use array of parameterized type (generics)as it causes some issue

Published by

Unknown's avatar

sevanand yadav

software engineer working as web developer having specialization in spring MVC with mysql,hibernate

Leave a comment