Suppress deprecated import warning in Java

前端 未结 6 1965
不思量自难忘°
不思量自难忘° 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条回答
  •  不知归路
    2020-11-27 06:41

    you can use:

    javac FileName.java -Xlint:-deprecation

    But then this will give you warnings and also tell you the part of the code that is causing deprecation or using deprecated API. Now either you can run your code with these warnings or make appropriate changes in the code.

    In my case I was using someListItem.addItem("red color") whereas the compiler wanted me to use someListItem.add("red color");.

提交回复
热议问题