Java Generics : Is any meta information about the generic type preserved at runtime as well?

后端 未结 6 1052
自闭症患者
自闭症患者 2021-01-14 06:13

Background

My understanding of Java generics is it being completely a compile time feature (mainly focusing on type safety checks)

6条回答
  •  误落风尘
    2021-01-14 06:58

    Generic information only persist till compile time .In your example as well it is available till compile time. Let me explain it with one example

    Public void printObject( list empt) {

    // This don't shows that list keep this information at runtime that what type of object it will return . Employment en =empt.get(); }

提交回复
热议问题