"Unreachable code"是什么错误?
我在使用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>
以下是具体的程序代码:
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>
...全文
相关推荐
CCIE 北京面试整理
值得注意的几种类型包括: - Echo-Request (Type 8, Code 0) - Echo-Reply (Type 0, Code 0) - Unreachable (Type 3, Code
ICMP TYPE CODE 对应表.docx
ICMP 报文由Type(类型)和Code(代码)两部分组成,分别用于指定报文的类型和具体的错误代码。本文将对 ICMP TYPE CODE 对应表进行详细的解释。
icmp_type and code.docx
目的地不可达目的地不可达是一类重要的错误报告,Type 3表示目的地不可达,其Code值进一步指明了不可达的具体原因:- **Code 0**: Network Unreachable - 网络不可达。
C语言上机程序调试功能键及常见错误提示
- Unreachable code:无法执行的代码,检查是否有逻辑错误导致部分代码被跳过。2.
编程备查ASPNET编译执行常见错误及解决方法53条汇总[总结].pdf
Unreachable code detected 代码中有无法执行的部分,通常是由于异常处理或返回语句的位置不当。确保throw或return语句位于最后。7.


Eclipse
