新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论Java, J2SE, J2ME, J2EE, 以及Eclipse, NetBeans, JBuilder等Java开发环境,还有JSP, JavaServlet, JavaBean, EJB以及struts, hibernate, spring, webwork2, Java 3D, JOGL等相关技术。
    [返回] 计算机科学论坛计算机技术与应用『 Java/Eclipse 』 → 简单的语法错误 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 4700 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 简单的语法错误 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     xsh8hf 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:57
      门派:XML.ORG.CN
      注册:2007/12/25

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给xsh8hf发送一个短消息 把xsh8hf加入好友 查看xsh8hf的个人资料 搜索xsh8hf在『 Java/Eclipse 』的所有贴子 引用回复这个贴子 回复这个贴子 查看xsh8hf的博客楼主
    发贴心情 简单的语法错误

    public class LList implements ListInterface
    {
     private Node firstNode ;//引用第一个节点
            private int length;    //线性表中元素个数
            public LList()
     {
      clear();

     }
     
     public final void clear()
     {
      firstNode=null;
      length=0;
     }

     
     
     private class Node
     {
      private Object data;
      private Node next;
      
      private Node(Object dataPortion)
      {
       data=dataPortion;
       next=null;
      }
      private Node(Object dataPortion,Node nextNode)
      {
       data=dataPortion;
       next=nextNode;
      }
     }


            public boolean add(Object newEntry)
     {
      Node newNode=new Node(newEntry);
      if(isEmpty())
      {
       firstNode=newNode;
      }
      else
      {
       Node lastNode=getNodeAt(length);
       lastNode.next=newNode;
      }

      length++;
      return true;
     
     }

     public boolean add(int newPosition,Object newEntry)
     {
      boolean isSuccessful=true;
      if((newPosition>=1)&&(newPosition<=length+1))
      {
       Node newNode=new Node(newEntry);
       
       if((isEmpty())||(newPosition==1))//
       {
        newNode.next=firstNode;
        firstNode=newNode;
       }
       else
       {
        Node nodeBefore=getNodeAt(newPosition-1);
        Node nodeAfter=nodeBefore.next;
        newNode.next=nodeAfter;
        nodeBefore.next=newNode;
       }
       length++;
      }
      else
       isSuccessful=false;
      return isSuccessful;
      
     }

      private Node getNodeAt(int givenPosition)
      {
       Node currentNode=firstNode;
       for(int counter=1;counter<givenPosition;counter++)
       {
        currentNode=currentNode.next;
       }
       return currentNode;
      }

      public Object remove(int givenPosition)
      {
       Object result=null;
       if(!isEmpty()&&(givenPosition>=1)&&(givenPosition<=length))
       {
        if(givenPosition==1)
        {
         result=firstNode.data;
         firstNode=firstNode.next;
        }
        else
        {
         Node nodeBefore=getNodeAt(givenPosition-1);
         Node nodeToRemove=nodeBefore.next;
         Node nodeAfter=nodeToRemove.next;
         nodeBefore.next=nodeAfter;
         result=nodeToRemove.data;
        }
        length--;
       }
       return result;
      }

      public boolean replace(int givenPosition ,Object newEntry)
      {
       boolean isSuccessful=true;
       if(!isEmpty()&&(givenPosition>=1)&&(givenPosition<=length))
       {
        Node desiredNode=getNodeAt(givenPosition);
        desiredNode.data=newEntry;
       }
       else
        isSuccessful=false;
       return isSuccessful;
      }

      public Object getEntry(int givenPosition)
      {
       Object result=null;
       if(!isEmpty()&&(givenPosition>=1)&&(givenPosition<=length))
       result=getNodeAt(givenPosition).data;
       return result;
      }
      
      public boolean contains(Object anEntry)
      {
       boolean found=false;
       Node currentNode=firstNode;
       while(!found&&(currentNode!=null))
       {
        if(anEntry.equals(currentNode.next))
         found=true;
        else
         currentNode=currentNode.next;
       }
       return found;
      }
          public void display()
     {
      for(int i=length;i>0;i--)
      {
       System.out.println(getNodeAt(i).data);
      }
     }
          public int getLength()
          {

      return this.length;
         }
         public boolean isEmpty()
         {
     return length==0;
         }
         public int getLength()
     {
      return this.length;
     }
         public boolean isFull()
         {
     return false;
         }
         public static void main(String[] args)
     {
      LList Llist = new LList();

      for(int i=0;i<args.length;i++)
      {
       Llist.add(args[i]);
      }
      Llist.display();
     }


    }
    这个程序有一句语法错误,有没有高手能给我解决一下呢。


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/12/25 15:04:00
     
     xsh8hf 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:57
      门派:XML.ORG.CN
      注册:2007/12/25

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给xsh8hf发送一个短消息 把xsh8hf加入好友 查看xsh8hf的个人资料 搜索xsh8hf在『 Java/Eclipse 』的所有贴子 引用回复这个贴子 回复这个贴子 查看xsh8hf的博客2
    发贴心情 
    呜呜呜,没人会吗。。
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/12/26 12:22:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 Java/Eclipse 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/5/2 3:07:54

    本主题贴数2,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    3,529.297ms