Pau*_*ton 5 android android-studio
Android工作室似乎认为SparseArray价值观不可能null.
当我写作
public static void foo() {
SparseArray<Object> sparseArray = new SparseArray<Object>();
sparseArray.put(0, null);
if (sparseArray.valueAt(0) == null)
Log.d("MyClass", "Hello World");
}
Run Code Online (Sandbox Code Playgroud)
我收到了警告
条件'sparseArray.valueAt(0)== null'始终为'false'
我只想知道我需要提出什么注释或评论来消除警告.我不想禁用检查,只是摆脱这个特殊的警告.谢谢.
您可以在本地禁止检查//noinspection <inspectionname>.
例如:
//noinspection ConstantConditions
if (sparseArray.valueAt(0) == null)
Run Code Online (Sandbox Code Playgroud)
摆脱这个错误的警告.
| 归档时间: |
|
| 查看次数: |
455 次 |
| 最近记录: |