有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java需要帮助检查值是否为1

我需要检查一个值是否为-1。我编译的一些源代码有问题,我不知道如何解决here的问题

我知道我需要实施:

if(wifiManager.addNetwork(conf) == -1) {
    // Insert code to handle the failure here.
} else {
    // The rest of your code for the 'success' case here!
}

但我不确定应该插入什么来处理失败


共 (1) 个答案

  1. # 1 楼答案

    您可以通过在if语句中比较wifiManager.addNetwork(conf);的结果来完成此操作

    if(wifiManager.addNetwork(conf) == -1) {
        // Insert code to handle the failure here.
    } else {
        // The rest of your code for the 'success' case here!
    }
    

    我假设你在和Android's ^{}合作