Suppress deprecated import warning in Java

前端 未结 6 1952
不思量自难忘°
不思量自难忘° 2020-11-27 06:07

In Java, if you import a deprecated class:

import SomeDeprecatedClass;

You get this warning: The type SomeDeprecatedClass is deprecat

6条回答
  •  Happy的楠姐
    2020-11-27 06:32

    Suppose that you are overriding/implementing an interface with a deprecated method (such as the getUnicodeStream(String columnLabel) in java.sql.ResultSet) then you will not get rid of deprecation warnings just by using the annotation @SuppressWarnings( "deprecation" ), unless you also annotate the same new method with the @Deprecated annotation. This is logical, because otherwise you could "undeprecate" a method by just overriding its interface description.

提交回复
热议问题