请教: IF(){}ELSE{}的问题
本人对IF()}ELSE IF{}有一问题不清楚想请高手解释:TreeNodeBase two;
if (organization2.getType().equalsIgnoreCase("department")) {
two = new TreeNodeBase("rootNode-link",
organization2.getName(), false);
} else if (organization2.getType().equalsIgnoreCase("subbranch")) {
two = new TreeNodeBase("rootNode", organization2.getName(), false);
} else {
two = new TreeNodeBase("rootNode-link2",organization2.getName(), false);
}
two.setIdentifier(organization2.getOid().toString());
象上面的代码: TreeNodeBase two ;这样定义就可以了
但是如果条件变成
if (organization2.getType().equalsIgnoreCase("department")) {
two = new TreeNodeBase("rootNode-link",
organization2.getName(), false);
} else if (organization2.getType().equalsIgnoreCase("subbranch")) {
two = new TreeNodeBase("rootNode", organization2.getName(), false);
}
必须要初始化TreeNodeBase two =???
不知道为什么???