Crossed out imported java packages

前端 未结 2 1385
你的背包
你的背包 2020-12-12 05:28

In my java program, I have imported some java packages in one class. but in there 1 or 2 packages were crossed out.

Why that happened? How to solve this cross out to

相关标签:
2条回答
  • 2020-12-12 06:13

    Those classes are marked as @Deprecated.

    This means that the compiler advises not to use them, because they can bring you problems.

    A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists. Compilers warn when a deprecated program element is used or overridden in non-deprecated code.

    Check the javadoc(s) of the deprecated classes to check which classes to use instead.

    0 讨论(0)
  • 2020-12-12 06:15

    For the sake of completeness, there is a special case which looks like this in Eclipse:

    In the case above there exist three is() methods, which all are statically imported. Hoovering the crossed out method name doesn't give any information, and there isn't a warning marker like there is for @Deprecated classes. In other words, it can be tricky to understand what it means.

    In this case, one of the is() methods is @Deprecated, causing the behaviour.

    This behaviour was discussed here, a question which was closed as a duplicate.

    0 讨论(0)
提交回复
热议问题