有人能告诉我为什么我在 else 分支中收到死代码警告if (projectId != null)
吗?如果我做对了,解释器认为projectId
永远不能为空 - 对吗?在我看来这是不可能的...
Integer projectId = null;
if (!sprintTaskConnections.isEmpty())
projectId = sprintTaskConnections.get(0).getProjectId();
// init name, state, startDate, endDate here
JiraSprint sprint = new JiraSprint(sprintInfo.getInt("id"), name, state, projectId, startDate, endDate);
if (projectId != null)
{
...
}
即使我放了一个
sprintTaskConnections.add(new JiraSprintTaskConnection(1, 1, 1));
或一个
sprintTaskConnections.clear();
在...前面
if (!sprintTaskConnections.isEmpty())
projectId = sprintTaskConnections.get(0).getProjectId();
结果总是一样的!
请帮帮我,我只是现在不明白!