java 我使用@SuppressWarnings 的什么值来抑制“可以是私有的”警告?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38628679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 03:36:05  来源:igfitidea点击:

What value for @SuppressWarnings do I use to suppress the "Can be private" warning?

javaandroid-studiosuppress-warnings

提问by Ab?

I keep getting annoyed by the "Can be private" warning, however my FirebaseRecyclerAdapterwill not work in that case. So, is there a @SuppressWarningsfor that?

我一直对“可以是私人的”警告感到恼火,但是FirebaseRecyclerAdapter在这种情况下我不会工作。那么,有没有@SuppressWarnings呢?

What I've tried:

我试过的:

@SuppressWarnings("all")but that's not what I want.

@SuppressWarnings("all")但这不是我想要的。

Note:I am using Android Studio

注意:我使用的是 Android Studio

回答by Aerus

It is best to simply disable this inspection, either for your whole project or for a specific class. Put your cursor on the warning and press Alt+ Enterto bring up the following menu, which allows you to disable it:

最好为整个项目或特定类简单地禁用此检查。将光标放在警告上,然后按Alt+Enter以显示以下菜单,您可以将其禁用:

Disable inspection

禁用检查

If you reallywant to use @SuppressWarningsyou can choose the Suppress for classoption from the dialog above. This will add the following annotation:

如果您真的想使用,@SuppressWarnings您可以Suppress for class从上面的对话框中选择选项。这将添加以下注释:

@SuppressWarnings("WeakerAccess")