throws Exception 小问题

public int addUser(User user) throws Exception {

 

try {

userDao.save(user);

return user.getId();

} catch (RuntimeException e) {

e.printStackTrace();

throw new Exception("新增用户异常");  //这个地方,如果注释掉这句话  ,要return 0;

}

}

 

 

throw new Exception("新增用户异常");  //这个地方,如果注释掉这句话  ,要return 0;

 

加上这句话就不用写返回值了,怎么回事?? 有高手给解答一下

你可能感兴趣的:(exception)