当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: printsetupprinter()函数在win2000下编译后在98下不能使用,在98 下编译后在2000下不能使用,谁有好的解决方法? ......
 ·jsp连接mysql,删除数据出错.    »显示摘要«
    摘要: <%@ page contenttype="text/html; charset=gbk" %> <html> <head> <title> delete employee processing </title> </head> <%@ page language="java&quo......


返回方法的类型问题.

请看看我这个程序:  
  public   List   selectOperation   (String   snum)   throws   SAXException,ParserConfigurationException,TransformerConfigurationException,TransformerException,IOException  
    {  
        DocumentBuilderFactory   factory   =   DocumentBuilderFactory.newInstance();  
        DocumentBuilder   builder   =   factory.newDocumentBuilder();  
        Document   doc   =   builder.parse("DateFile.xml");  
        doc.normalize();  
   
        NodeList   nodelist   =   doc.getElementsByTagName("AAB001");  
        for   (int   i=0;i<nodelist.getLength();i++)  
        {  
            if   (nodelist.item(i).getFirstChild().getNodeValue()==snum)  
            {  
                NodeList   node   =   nodelist.item(i).getParentNode().getChildNodes();  
                List   list   =   new   ArrayList();  
   
                for   (int   j=0;j<node.getLength();j++)  
                {  
                    String   s   =   node.item(j).getFirstChild().getNodeValue();  
                    list.add(j,s);  
                }  
                return   list;  
              }  
          }  
      }  
   
  我想在DateFile.xml内找到节点AAB001的值等于SNUM的所有兄弟节点,然后输出他们的值,然后在别的类里调用,但我不太清楚方法的返回类型是不是该这么设,我测试时有错:  
  "NodeDOM.java":   Error   #:   466   :   method   does   not   return   a   value   at   line26,   column   2

NO.1   作者: wyalchemy

老天,当你的:  
  if   (nodelist.item(i).getFirstChild().getNodeValue()==snum)  
  条件一直不成立的时候,你的方法根本就没有正确返回呀!

NO.2   作者: jgo

if   语句外要有return   list。因为如果你的if不成立的话,就没有return语句来。

NO.3   作者: wangwenyou

你必须把它放到for外面,并在for以后return


    摘要: 怎样用asp或者asp.net编程,实现让用户修改echange server2000邮箱的密码? ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE