سؤال

If I do this:

public class IntegerList extends ArrayList < Integer > { }

Am I able to use IntegerList normally without worrying about type erasure, meaning I can use and create arrays of them and instantiate them dynamically, and any compliant compiler or IDE will be able to do both compile- and run-time type checking properly?

هل كانت مفيدة؟

المحلول

Yes, IntegerList is a reified type, which is what I think you're trying to say.

And while we are at it, ArrayList is also a reified type, which means you can do the same things with ArrayList that you can do with IntegerList. (But not with ArrayList<Integer>, which is not a reified type.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top