java - Array w/ Generics -
i have read what's reason can't create generic array types in java? . came when tried code:
hashmap<string, string>[] ret = new hashmap<string, string>[arraysize];
i decided "get wild" , try else
arraylist<hashmap<string, string>> ret = new arraylist<hashmap<string, string>>();
now, don't understand why first option bad/not-supported , second option compiles.
what missing? in first method error , cannot compile while second method has no compiler issues.
i prefer follow intelligent programming principles, not understand difference in particular case.
to point out know, second 1 compiles. arraylist not array, your program won't run generic array problem.
you're wondering how arraylist
then. in implementation of arraylist
i've seen, internally uses object
array--not generic. class lot of casting.
Comments
Post a Comment