Unreachable code

来源:互联网 发布:voltage drop 算法 编辑:程序博客网 时间:2024/05/29 14:50

今天写了一段Java代码,不小心出了“Unreachable code”错误,开始的时候MyEclipse一直提示我要我重命名一个对象,但我重命名了也不好用,最后才看到这个“Unreachable code”错误,在网上调查了一下,这个错误翻译成中文就是“不可达到的代码”,就是我写的代码是有一部分是怎么执行程序也不能走到的。

看看我的代码是这样写得:

public class TestElAction extends Action {

 public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest req, HttpServletResponse res){
  //字符串
  req.setAttribute("hello", "HelloWorld!");
  return mapping.findForward("testEl");        //出问题的关键在着,这里已经结束程序啦,下面还有代码,

                                                                      //当然会出“不可达到”的错误
  
  //结构
  Group group = new Group();                      //出问题的代码在这
  group.setName("学习系");
  
  User user = new User();
  user.setName("张三");
  user.setAge(19);
  user.setGroup(group);
  
 }

}

原创粉丝点击