Type safety: unchecked cast from object to

First of all, the Java language lab is type safe. We usually encounter this problem when the object is converted to the target type

This transformation is not safe. This problem is generally believed to be caused by the use of JDK1.5 or 1.6 generics

Request. Getattribute (“* *”) gets a type that defaults to object. When you convert them to list & lt***> When

The compiler thinks that there may be errors, so it prompts that this type is safe

But how to remove this warning?The following is a common way to remove the warning (but the danger has not been removed)

1: Method to add @ suppresswarnings (“unchecked”)

2: Eclipse’s window – > Preferences-> Java-> Compiler-> Errors/Warning-> In generic types, unchecked generic type operation is set to ignore

3: Eclipse’s window – > Preferences-> Java-> Compiler sets compiler compliance level to less than 1.5

Similar Posts: