View RSS Feed

Advanced Java

Advanced Java programming.

  1. Use Lists instead Arrays in Generics

    by , 11-30-2011 at 12:20 AM
    Generics were added to java in release 1.5. It allows you to avoid needing to cast objects as they are read from a collection. Instead you tell the compiler what types of objects that you want to hold in the collection. Often it is difficult to know which generic to use when you have two or more who seem to be able to complete the same function. Consider the choice between whether to use a list or an array. Now a key thing to remember is that arrays are covariant and know and enforce their element ...