[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: java.util.Hashtable.size()/isEmpty()

From: Artur Biesiadowski
Subject: Re: java.util.Hashtable.size()/isEmpty()
Date: Fri, 15 Feb 2002 11:41:22 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8+) Gecko/20020202

Sascha Brawer wrote:

    * Returns true if there are no key-value mappings currently in this table.
    * @return <code>size() == 0</code>
-  public synchronized boolean isEmpty()
+  public boolean isEmpty()
+    /* This method does not need to be synchronized
+     * because accessing an integer field is atomic.
+     */
     return size == 0;

If we are on the subject, I think it should check for
size() == 0
, not
size == 0
as subclasses would rather think that overriding size() is enough, not caring about overriding isEmpty(). Either that, or change the javadoc, but I think that size() == 0 would be more in line with sun spec - and OO-progamming in general :)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]