"Unreachable code"是什么错误?

Mario_cn Mario_cn 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在使用Eclipse写Java代码时报了这个错误,请明白人告知一下这个错误该如何解释?谢谢

以下是具体的程序代码:
package domprinter;

import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

public class DOMPrinter
{
/*
* 输出节点的名字和节点的值
*/
public static void printNodeInfo(Node node)
{
System.out.println(node.getNodeName() + " : " + node.getNodeValue());
}
/*
* 采用递归调用,输出指定节点下的所有后代节点
*/
public static void printNode(Node node)
{
short nodeType = node.getNodeType();
switch(nodeType)
{
case Node.PROCESSING_INSTRUCTION_NODE:
System.out.println("*****PI start*****");
printNodeInfo(node);
System.out.println("*****PI end*****");
break;
case Node.ELEMENT_NODE:
System.out.println("*****ELEMENT start*****");
printNodeInfo(node);
System.out.println("*****ELEMENT end******");
break;

NamedNodeMap attrs = node.getAttributes();
int attrNum = attrs.getLength();
for(int i=0;i<attrNum;i++)
{
Node attr = attrs.item(i);
System.out.println("*****Attribute start*****");
printNodeInfo(attr);
System.out.println("*****Attribute end*****");
}
break;

case Node.TEXT_NODE:
System.out.println("*****Text start*****");
printNodeInfo(node);
System.out.println("*****Text end*****");
break;
default:
break;
}

Node child = node.getFirstChild();
while(child != null)
{
printNodeInfo(child);
child = child.getNextSibling();
}
}
public static void main(String[] args)
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try
{
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File("students.xml"));
printNode(doc);
}
catch(ParserConfigurationException e){e.printStackTrace();}
catch(SAXException e){e.printStackTrace();}
catch(IOException e){e.printStackTrace();}
}
}

students.xml:

<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xml" href="students.xml"?>
<!DOCTYPE students [
<!ELEMENT students (student*)>
<!ELEMENT student (name,age)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
]>

<students>
<student sn="01">
<name>张三 </name>
<age>18 </age>
</student>

<student sn="02">
<name>李四 </name>
<age>20 </age>
</student>
</students>
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
Mario_cn
Eclipse 58,439 成员 49,457 内容