Skip to content

Why do instantiations of generic types share the same runtime type? #10

@ThomsonTang

Description

@ThomsonTang

Because of type erasure.

the compiler translates the generic and parameterized types by a technique called type erasure. Basically, the compiler elides all information related to type parameters and type arguments.

For instance, ArrayList<String> and ArrayList<Long> have the same raw type ArrayList after the type erasure.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions