三汪
2017-08-21 01:06Java中的dead code原因分析,可有大牛解惑?
dead code的原因是代码无意义。在下面方法中return null;报dead code警告。但是不加这句return null必然是不行的。会报错。因此不是很理解为什么会提示dead code。可有人解惑?
@RequestMapping(value = "/student/get" , method = RequestMethod.GET)
public Student getStudent(@RequestParam(value="name",required=false)String name) throws BizException{
if (name.equals("Chaves")) {
throw new BizException("Chaves is invalid!");
}
if (name != null) {
return studentService.findByName(name);
}
return null;
}
- 点赞
- 回答
- 收藏
- 复制链接分享
4条回答
为你推荐
- 当匿名函数在golang中永远等待通道时会发生什么?
- lambda
- channel
- 1个回答
- 如何在没有PHP Semaphore的情况下在PHP中实现信号量?
- semaphore
- wordpress
- php
- 2个回答
- 如何阻止某些单词/字母在PHP中交换?
- html
- php
- 1个回答
- 我可以教PHPUnit Mage :: throwException *总是*抛出异常吗?
- magento
- code-coverage
- php
- 1个回答
- centos7下,tomcat启动成功,但页面无法访问
- spring
- java
- tomcat
- 5个回答
换一换