generics - Why using weak typing array for Vector, ArrayList and the whole Java collection framework -


i wondering why didn't vector api (as others) choose use strong typing underlying array code below ? why using week typing object ? isn't better strong typing type safety resolved in compile time ?

public class vector<e> {     private static final initialcapacity = 2;     protected e[] elementdata;      private vector(class<e> c) {         @suppresswarnings("unchecked")         final e[] elementdata = (e[]) array.newinstance(c, initialcapacity);     }    } 

vector, arraylist, , whole collections framework written before generics thing in first place. didn't have alternative @ point, , had left way backwards compatibility.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -

PHPMotion implementation - URL based videos (Hosted on separate location) -