首页> 开发问题 >其它问题 其它问题
Unreachable statement
作者:小萝卜 2019-11-29 【 漏洞BUG 】 浏览 1480
简介Unreachable statement
public boolean onQueryTextSubmit(String s) {
if (sv != null) {
// 得到输入管理对象
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
// 这将让键盘在所有的情况下都被隐藏,但是一般我们在点击搜索按钮后,输入法都会乖乖的自动隐藏的。
imm.hideSoftInputFromWindow(sv.getWindowToken(), 0); // 输入法如果是显示状态,那么就隐藏输入法
}
sv.clearFocus(); // 不获取焦点
}
//将输入数据传入classinfo中
Intent intent=new Intent(ClassSearch.this,ClassInfo.class);
intent.putExtra("infoData",s);
startActivity(intent);
return true;
try {
ClientKey.put("classID", s);
Authorization.put("Class",ClientKey);
String content = String.valueOf(Authorization);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setConnectTimeout(5000);
//设置允许输出
conn.setDoOutput(true);
conn.setRequestMethod("POST");
//设置contentType
conn.setRequestProperty("Content-Type","application/json");
OutputStream os = conn.getOutputStream();
os.write(content.getBytes());
os.close();
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
ClientKey.put("classID", s);
这一行出现unreachable statement , 往前看,在try前面出现了return,所以永远不能到达这一行
P.S.这种基础错误很容易犯,以后要注意。
很赞哦! (0)
相关文章
- tf.matmul()报错expected scalar type Float but found Double
- matlab命令行双箭头消失
- clion ctrl+鼠标左键不能调到函数实现
- datagrid MAC和VPNIP显示不出来,Time显示错误的问题
- MapReduce报错:Error: java.io.IOException: Initialization of all the collectors failed. Error in last collector was :interface javax.xml.soap.Text
- Android Studio安装&&安装bug
- pycharm无法识别自己的文件夹的程序
- Attempt to invoke interface method 'boolean java.util.List.add(java.lang.Object)' on a null object reference
- idea maven 报-source 1.5 中不支持 diamond 运算符
- GitHub 上传文件过大报错:remote: error: GH001: Large files detected.