Hashtable ht=new  Hashtable();
    ht.put("1",11);
    ht.put("2",22);
    ht.put("3",33);
   isExisUser("1"); //居然报错,真气人呀 public boolean isExisuser(String name)//根据一个名字判断是否在集合里面
    {
       Enumeration e=ht.keys();
       while(e.hasMoreElements())
       {
           System.out.println(e.nextElement());
           if(e.nextElement().equals(name))
               return true;              
       }      
        return false;
    }

解决方案 »

  1.   

    isExisUser("1");public boolean isExisuser(String name)方法名写错了,应该是 isExisuser("1")
      

  2.   

    判断在不在里面用得着这样吗,
    可以考虑用HashMap代替HashTable,然后return map.containsKey("1")不就好了containsKey
    public boolean containsKey(Object key)Returns true if this map contains a mapping for the specified key. Specified by:
    containsKey in interface Map
    Overrides:
    containsKey in class AbstractMap
    Parameters:
    key - The key whose presence in this map is to be tested 
    Returns:
    true if this map contains a mapping for the specified key.
      

  3.   

    Hashtable有contains、containsKey、containsValue等方法可以判断一个key或value是否在容器中,为什么还要自己实现呢?效率也没有jdk的高
      

  4.   

    刚在做作业.不直没上线.
    不好意思.
    后来我才发现是这里错了.
     System.out.println(e.nextElement()(问题在这里我又往下移了下));
               if(e.nextElement().equals(name))
                   return true;              
    所以下面就报了个枚举超出.zhigangsun(流星) 说的很对.后来我才发现.有这个方法..
    我是个新手.刚学J2ee.不过为期也就一个月.希望以后能碰到你们.