这是代码的节选:
if (resultText.equalsIgnoreCase("open browser"))
{
try{
Process p; //resultText="";
p = Runtime.getRuntime().exec("cmd /c start chrome.exe");
}catch(Exception ae){}
}
在日食中显示警告为:
The value of local variable p is not used
这是怎么了请帮助我理解问题。谢谢。
最佳答案
这只是来自IDE的警告。这不是错误。只是让您知道p
从未被使用过。您可以将代码编写为:
if (resultText.equalsIgnoreCase("open browser"))
{
try{
Runtime.getRuntime().exec("cmd /c start chrome.exe");
}catch(Exception ae){}
}
而且它将做同样的事情。