<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Array puzzler</title>
	<atom:link href="http://tech.puredanger.com/index.php/2007/03/27/array-puzzler/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.puredanger.com/2007/03/27/array-puzzler/</link>
	<description>Alex Miller&#039;s technical blog</description>
	<lastBuildDate>Mon, 06 Feb 2012 19:39:50 -0800</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
	<item>
		<title>By: Stefan Schulz</title>
		<link>http://tech.puredanger.com/2007/03/27/array-puzzler/comment-page-1/#comment-1551</link>
		<dc:creator>Stefan Schulz</dc:creator>
		<pubDate>Thu, 29 Mar 2007 19:10:03 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2007/03/27/array-puzzler/#comment-1551</guid>
		<description>Simon: Unfortunately, Object.equals does not cover arrays (which only tests for identity). That&#039;s the main reason for me using Arrays.deepEquals which cares about the various primitive arrays, too.</description>
		<content:encoded><![CDATA[<p>Simon: Unfortunately, Object.equals does not cover arrays (which only tests for identity). That&#8217;s the main reason for me using Arrays.deepEquals which cares about the various primitive arrays, too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://tech.puredanger.com/2007/03/27/array-puzzler/comment-page-1/#comment-1538</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Thu, 29 Mar 2007 10:30:38 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2007/03/27/array-puzzler/#comment-1538</guid>
		<description>Previous post code example referenced a method
   notNull( o1 ) which was omitted (apologies to Stefan).
Here are notNull() and isNull() upon which it depends.

    /**
     *  Tests whether aObject is null.
     *
     * @param  aObject the Object to be tested for nullity
     *
     * @return  true if aObject is null, false otherwise
     */
    public final static boolean isNull( final Object aObject ){
        return areIdentical( aObject, null );
    }

    /**
     *  Tests whether aObject is non-null.
     *
     * @param  aObject the Object to be tested for non-nullity
     *
     * @return  false if aObject is null, true otherwise
     */
    public final static boolean notNull( final Object aObject ){
        return not( isNull( aObject ) );
    }</description>
		<content:encoded><![CDATA[<p>Previous post code example referenced a method<br />
   notNull( o1 ) which was omitted (apologies to Stefan).<br />
Here are notNull() and isNull() upon which it depends.</p>
<p>    /**<br />
     *  Tests whether aObject is null.<br />
     *<br />
     * @param  aObject the Object to be tested for nullity<br />
     *<br />
     * @return  true if aObject is null, false otherwise<br />
     */<br />
    public final static boolean isNull( final Object aObject ){<br />
        return areIdentical( aObject, null );<br />
    }</p>
<p>    /**<br />
     *  Tests whether aObject is non-null.<br />
     *<br />
     * @param  aObject the Object to be tested for non-nullity<br />
     *<br />
     * @return  false if aObject is null, true otherwise<br />
     */<br />
    public final static boolean notNull( final Object aObject ){<br />
        return not( isNull( aObject ) );<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://tech.puredanger.com/2007/03/27/array-puzzler/comment-page-1/#comment-1536</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Thu, 29 Mar 2007 10:25:03 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2007/03/27/array-puzzler/#comment-1536</guid>
		<description>What I wish the Object class had is a method
    boolean is(Object obj) 
which wraps ( myObj == obj ) so have object-orientated method when know myObj is non-null.

For Stefan:
(1) a null-safe equals() method which depends upon (2) areIdentical() which hides == so that I don&#039;t use single = by mistake.

I have these in an Object utility class I call ObjectUtil.

    /**
     *  Tests any two Objects ( including the case of two nulls ) for equality.
     *
     * @param  o1 the first Object to be tested
     * @param  o2 the second Object to be tested
     *
     * @return  true if the two objects are equal, false otherwise
     */
    public final static boolean areEqual( final Object o1, final Object o2 ){
        return areIdentical( o1, o2 ) &#124;&#124; ( notNull( o1 ) &amp;&amp; o1.equals( o2  ) );
    }



    /**
     *  Tests any two Objects for identity.
     *
     * @param  o1 the first Object to be tested
     * @param  o2 the second Object to be tested
     *
     * @return  true if the two objects are identical, false otherwise
     */
    public final static boolean areIdentical( final Object o1, final Object o2 ){
        return ( o1 == o2 );
    }</description>
		<content:encoded><![CDATA[<p>What I wish the Object class had is a method<br />
    boolean is(Object obj)<br />
which wraps ( myObj == obj ) so have object-orientated method when know myObj is non-null.</p>
<p>For Stefan:<br />
(1) a null-safe equals() method which depends upon (2) areIdentical() which hides == so that I don&#8217;t use single = by mistake.</p>
<p>I have these in an Object utility class I call ObjectUtil.</p>
<p>    /**<br />
     *  Tests any two Objects ( including the case of two nulls ) for equality.<br />
     *<br />
     * @param  o1 the first Object to be tested<br />
     * @param  o2 the second Object to be tested<br />
     *<br />
     * @return  true if the two objects are equal, false otherwise<br />
     */<br />
    public final static boolean areEqual( final Object o1, final Object o2 ){<br />
        return areIdentical( o1, o2 ) || ( notNull( o1 ) &amp;&amp; o1.equals( o2  ) );<br />
    }</p>
<p>    /**<br />
     *  Tests any two Objects for identity.<br />
     *<br />
     * @param  o1 the first Object to be tested<br />
     * @param  o2 the second Object to be tested<br />
     *<br />
     * @return  true if the two objects are identical, false otherwise<br />
     */<br />
    public final static boolean areIdentical( final Object o1, final Object o2 ){<br />
        return ( o1 == o2 );<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Schulz</title>
		<link>http://tech.puredanger.com/2007/03/27/array-puzzler/comment-page-1/#comment-1506</link>
		<dc:creator>Stefan Schulz</dc:creator>
		<pubDate>Wed, 28 Mar 2007 20:33:26 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2007/03/27/array-puzzler/#comment-1506</guid>
		<description>You already mentioned Arrays.deepEquals in your post. Actually, I wished an Objects utility class would be introduced, which provides null-safe equals and deepEquals methods to compare objects (and maybe other null-safe ones). Arrays.deepEquals already does so, only one has to wrap objects in single-object arrays (which is a bit goofy).</description>
		<content:encoded><![CDATA[<p>You already mentioned Arrays.deepEquals in your post. Actually, I wished an Objects utility class would be introduced, which provides null-safe equals and deepEquals methods to compare objects (and maybe other null-safe ones). Arrays.deepEquals already does so, only one has to wrap objects in single-object arrays (which is a bit goofy).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://tech.puredanger.com/2007/03/27/array-puzzler/comment-page-1/#comment-1497</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Wed, 28 Mar 2007 13:36:19 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2007/03/27/array-puzzler/#comment-1497</guid>
		<description>Doh!  Absolutely right.  Thank you Guillaume.</description>
		<content:encoded><![CDATA[<p>Doh!  Absolutely right.  Thank you Guillaume.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

