<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mark W. Shead &#187; Java</title>
	<atom:link href="http://blog.markwshead.com/category/technology/programming/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.markwshead.com</link>
	<description>Mark's thoughts on being Mark Shead and other random subjects</description>
	<lastBuildDate>Mon, 02 Jan 2012 16:04:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Lucene MoreLikeThis Example Code</title>
		<link>http://blog.markwshead.com/966/lucene-morelikethis-example-code/</link>
		<comments>http://blog.markwshead.com/966/lucene-morelikethis-example-code/#comments</comments>
		<pubDate>Thu, 26 May 2011 23:10:09 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/?p=966</guid>
		<description><![CDATA[I was recently working on a simple application where the user will enter famous quotations.  Obviously we want to avoid duplicates so I needed a way to check for quotations that were substantially similar before a new quote was added to the database. The idea was to show the top 5 most similar quotes before letting the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I was recently working on a simple application where the user will enter <a href="http://www.noteaquote.com/">famous quotations</a>.  Obviously we want to avoid duplicates so I needed a way to check for quotations that were substantially similar before a new quote was added to the database.</p>
<p>The idea was to show the top 5 most similar quotes before letting the user save the new quotation to the db. I used Lucene for this which allowed me to punt on the more difficult task of figuring out if two quotes were similar or not. I left that up to Lucene and only had to worry about how to get my information in and out of Lucene in a usable manner.</p>
<p>Below is the interesting method that uses Lucene to build an index of all the quotes in the system and then returns the five quotes that are most similar to the new quote text.  Obviously creating a new index each time a quote is added isn&#8217;t particularly efficient, but makes it easier to demonstrate how it works and processor efficiency isn&#8217;t much of an issue with this particular task.</p>
<pre class="brush: java; title: ; notranslate">
    public List&lt;Quote&gt; getSimilarQuotes() throws CorruptIndexException, IOException {

        String quoteText = quote.getText();
        logger.info(&quot;creating RAMDirectory&quot;);
        RAMDirectory idx = new RAMDirectory();
        IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_31, new StandardAnalyzer(Version.LUCENE_31));
        IndexWriter writer = new IndexWriter(idx, indexWriterConfig);

        List&lt;Quote&gt; quotes =  session.createCriteria(Quote.class).list();

        //Create a Lucene document for each quote and add them to the
        //RAMDirectory Index.  We include the db id so we can retrive the
        //similar quotes before returning them to the client.
        for (Quote quote : quotes) {
            Document doc = new Document();
            doc.add(new Field(&quot;contents&quot;, quote.getText(),Field.Store.YES, Field.Index.ANALYZED));
            doc.add(new Field(&quot;id&quot;, quote.getId().toString() ,Field.Store.YES, Field.Index.ANALYZED));
            writer.addDocument(doc);
        }

        //We are done writing documents to the index at this point
        writer.close();

        //Open the index
        IndexReader ir = IndexReader.open(idx);
        logger.info(&quot;ir has &quot; + ir.numDocs() + &quot; docs in it&quot;);
        IndexSearcher is = new IndexSearcher(idx, true);

        MoreLikeThis mlt = new MoreLikeThis(ir);

 		//lower some settings to MoreLikeThis will work with very short
        //quotations
        mlt.setMinTermFreq(1);
        mlt.setMinDocFreq(1);

		//We need a Reader to create the Query so we'll create one
        //using the string quoteText.
        Reader reader = new StringReader(quoteText);

        //Create the query that we can then use to search the index
        Query query = mlt.like( reader);

        //Search the index using the query and get the top 5 results
        TopDocs topDocs = is.search(query,5);
        logger.info(&quot;found &quot; + topDocs.totalHits + &quot; topDocs&quot;);

        //Create an array to hold the quotes we are going to
        //pass back to the client
        List&lt;Quote&gt; foundQuotes = new ArrayList&lt;Quote&gt;();
        for ( ScoreDoc scoreDoc : topDocs.scoreDocs ) {
            //This retrieves the actual Document from the index using
            //the document number. (scoreDoc.doc is an int that is the
            //doc's id
            Document doc = is.doc( scoreDoc.doc );

            //Get the id that we previously stored in the document from
            //hibernate and parse it back to a long.
            String idField =  doc.get(&quot;id&quot;);
            long id = Long.parseLong(idField);

            //retrieve the quote from Hibernate so we can pass
            //back an Array of actual Quote objects.
            Quote thisQuote = (Quote)session.get(Quote.class, id);

            //Add the quote to the array we'll pass back to the client
            foundQuotes.add(thisQuote);
        }

        return foundQuotes;
    }
</pre>
<h4>People Found This When Looking For:</h4><ul><li>lucene indexwriterconfig (168)</li><li>lucene example (150)</li><li>lucene morelikethis (109)</li><li>IndexWriterConfig example (90)</li><li>IndexWriterConfig (51)</li><li>morelikethis lucene (38)</li><li>lucene indexwriterconfig example (34)</li><li>lucene more like this (33)</li><li>lucene examples (31)</li><li>lucene morelikethis example (30)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/966/lucene-morelikethis-example-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Java Thinks There Are 13 Months</title>
		<link>http://blog.markwshead.com/821/java-thinks-there-are-13-months/</link>
		<comments>http://blog.markwshead.com/821/java-thinks-there-are-13-months/#comments</comments>
		<pubDate>Sat, 18 Dec 2010 19:13:23 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/?p=821</guid>
		<description><![CDATA[I was working on a component for credit card processing where I needed to get the months of the year. Trying to plan ahead, I decided to use the DateFormatSymbols so it could easily handle localization if it ever needed to be used in a different language. It wasn&#8217;t doing what I expected and I [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I was working on a component for credit card processing where I needed to get the months of the year.  Trying to plan ahead, I decided to use the DateFormatSymbols so it could easily handle localization if it ever needed to be used in a different language.</p>
<p>It wasn&#8217;t doing what I expected and I finally found the problem with the following code:</p>
<pre class="brush: java; title: ; notranslate">
DateFormatSymbols symbols = new DateFormatSymbols();
String[] months = symbols.getMonths();
int numOfMonths = months.length
System.out.println(numOfMonths);
</pre>
<p>The output is 13. If you list all of the strings in the <code>months</code> array, you&#8217;ll find the first 12 are what you&#8217;d expect, but there is a 13th blank month at the end.</p>
<p>It turns out that there are some lunar based calendars that have to add a &#8220;leap month&#8221; every so many years.  This month is called Undecimber and comes after December. However, I&#8217;m not clear why Java is giving me a blank month.  If the given locale only has 12 months, what is the value of giving back a 13 item array and just leaving one blank?</p>
<h4>People Found This When Looking For:</h4><ul><li>are there 13 months (5)</li><li>java 13 month (3)</li><li>java 13 months (3)</li><li>java 13th month (3)</li><li>there are 13 months (3)</li><li>DateFormatSymbols 13 months (3)</li><li>java month 13 (2)</li><li>Is there 13 months (2)</li><li>java months 13 (2)</li><li>WAS THERE 13 MONTH (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/821/java-thinks-there-are-13-months/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Changing User Agent in Rome</title>
		<link>http://blog.markwshead.com/104/changing-user-agent-in-rome/</link>
		<comments>http://blog.markwshead.com/104/changing-user-agent-in-rome/#comments</comments>
		<pubDate>Wed, 19 Oct 2005 16:06:28 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/archives/2005/10/19/changing-user-agent-in-rome.html</guid>
		<description><![CDATA[Changing the user agent in Rome FeedFetcher doesn't quite work like you'd expect.  Here is how to get it to work so you can change it so you aren't stuck with "Java/1.5.0_04".  Some sites actually block "Java/1.5.0_04" so this is something worth changing if you want to pull in RSS feeds.]]></description>
			<content:encoded><![CDATA[<p></p><p>If you are trying to use Rome and Rome Feed Fetcher, you may want to change the user agent.  However, the following will not change the default user agent:</p>
<pre><code>
FeedFetcher feedFetcher = new HttpURLFeedFetcher();
feedFetcher.setUserAgent("User Agent 007");
SyndFeed feed = null;
feedURL = new URL(rssUrl);
feed = feedFetcher.retrieveFeed(feedURL);
List entries = feed.getEntries();
</code></pre>
<p>To change the user agent you must use the InfoCache as shown:</p>
<pre><code>
FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
feedFetcher.setUserAgent("User Agent 007");
SyndFeed feed = null;
feedURL = new URL(rssUrl);
feed = feedFetcher.retrieveFeed(feedURL);
List entries = feed.getEntries();
</code></pre>
<p>Otherwise the User agent is set to &#8220;Java/1.5.0_04&#8243;.  This is odd because the default client for Rome is &#8220;Rome Client (http://tinyurl.com/64t5n) Ver: 0.7&#8243;.  It seems like an attempt to change the user agent without having a HashMapFeedInfoCache will result in changing the user agent, but somehow it reverts to &#8220;Java/1.5.0_04&#8243; instead of whatever you set it to.</p>
<h4>People Found This When Looking For:</h4><ul><li>Rome client (34)</li><li>rome user agent (7)</li><li>rome user-agent (5)</li><li>rome useragent (4)</li><li>agent rome (2)</li><li>selenium change user agent (2)</li><li>user agent Rome Client (2)</li><li>Rome Client user-agent (2)</li><li>feedfetcher rome (2)</li><li>rome syndfeed user agent (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/104/changing-user-agent-in-rome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cobertura</title>
		<link>http://blog.markwshead.com/92/cobertura/</link>
		<comments>http://blog.markwshead.com/92/cobertura/#comments</comments>
		<pubDate>Sun, 10 Jul 2005 19:43:58 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/archives/2005/07/10/cobertura.html</guid>
		<description><![CDATA[Cobertura is a fork of jCoverage. It runs reports to let you see how much of your code is being tested by unit tests. This is incredibly useful to find areas of your code where a bug would go undetected. It looks like there is a plugin for Maven already, so I&#8217;m going to have [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Cobertura is a fork of jCoverage.  It runs reports to let you see how much of your code is being tested by unit tests.  This is incredibly useful to find areas of your code where a bug would go undetected.</p>
<p>It looks like there is a plugin for Maven already, so I&#8217;m going to have to give it a try sometime.  <a href="http://cobertura.sourceforge.net/">link</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/92/cobertura/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven Runs out of Memory</title>
		<link>http://blog.markwshead.com/89/maven-runs-out-of-memory/</link>
		<comments>http://blog.markwshead.com/89/maven-runs-out-of-memory/#comments</comments>
		<pubDate>Sat, 02 Jul 2005 20:00:15 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/archives/2005/07/02/maven-runs-out-of-memory.html</guid>
		<description><![CDATA[Maven 1.0 has some problems with memory leaks. Most of the time these aren&#8217;t issues, but if you are trying to compile a multiproject you might run into problems. By default Maven tells java to let it have up to 256MB of ram. If you need to increase this you&#8217;ll need to open the maven.bat [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Maven 1.0 has some problems with memory leaks.  Most of the time these aren&#8217;t issues, but if you are trying to compile a multiproject you might run into problems.  By default Maven tells java to let it have up to 256MB of ram.  If you need to increase this you&#8217;ll need to open the maven.bat (windows) or maven.sh (unix) file and change the way that java is called.  Somewhere around line 118 (on the .bat file)you should see the following:</p>
<p><code>if "%MAVEN_OPTS%"=="" SET MAVEN_OPTS="-Xmx256m"</code></p>
<p>Change the line so it reads:</p>
<p><code>if "%MAVEN_OPTS%"=="" SET MAVEN_OPTS="-Xmx1000m"</code></p>
<p>This will give Maven 1GB of memory to work with.  While this doesn&#8217;t really solve the problem of the memory leak, it may give you enough space to keep the problem from crashing Maven.</p>
<p>You can also set MAVEN_OPTS by setting it up as a variable in your environment.  If you do this the environment will override anything you set in the .bat or .sh file.</p>
<h4>People Found This When Looking For:</h4><ul><li>maven out of memory (137)</li><li>maven increase memory (91)</li><li>increase maven memory (58)</li><li>maven outofmemory (36)</li><li>maven_opts memory (35)</li><li>maven_opts windows (35)</li><li>maven memory (29)</li><li>maven out of memory windows (23)</li><li>increase memory maven (20)</li><li>MAVEN_OPTS (18)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/89/maven-runs-out-of-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Java Won&#8217;t Get It Right</title>
		<link>http://blog.markwshead.com/53/why-java-wont-get-it-right/</link>
		<comments>http://blog.markwshead.com/53/why-java-wont-get-it-right/#comments</comments>
		<pubDate>Sun, 03 Apr 2005 18:28:04 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[WebObjects]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/archives/2005/04/03/why-java-wont-get-it-right.html</guid>
		<description><![CDATA[Why Java Won&#8217;t Get It Right is an interesting entry about some of the problems with Java technology. The best part is that it is written by someone who actually knows Java. A part that I particularly liked was: They over-architect everything. I’ve actually used a Java framework (I’m not gonna say which) that had [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.mattmccray.com/blog/archives/2005/03/19/why-java-wont-get-it-right/">Why Java Won&#8217;t Get It Right</a> is an interesting entry about some of the problems with Java technology.  The best part is that it is written by someone who actually knows Java.   A part that I particularly liked was:</p>
<blockquote><p>
They over-architect everything. I’ve actually used a Java framework (I’m not gonna say which) that had XML config files that configured more XML config files! That’s just silly.
</p></blockquote>
<p>The author makes comparisons to Ruby on Rails and talks about how he doesn&#8217;t think Java will ever have anything like Rails.</p>
<p>I&#8217;ve seen a few demos of Rails and it is impressive, but much of the functionality it gives you has been available in WebObjects for some time.  <strike>In fact I&#8217;ve met several Ruby developers that started with Rails and switched to WebObjects as their application got bigger.</strike> (<strong>Update:</strong> It turns out I was mistaken.  They switched from Ruby to Webobjects, but they were using a different web framework instead of Rails.)</p>
<p>There is an interesting <a href="http://weblog.rubyonrails.com/archives/2005/03/19/bla-bla-list-cloning-a-rails-app-in-rife/">comparison</a> between a Ruby project and a Java project posted on the Ruby on Rails site.  The code comparison is interesting because it shows how much Ruby does for you automatically if you know how to use it.  A lot of what Ruby is doing is giving you automatic setters and getters.</p>
<p>It would be interesting to see a comparison between the amount of code necessary to write a Ruby application and the same app in WebObjects, but when it comes down to actual productivity the language being used is rarely the bottleneck.  The skills of the programmer are by far the most important factor.  The tools available in the language are second and the language ranks third or lower.</p>
<p>Good tools have a huge impact on productivity.  Simple things like auto-complete and real time syntax checking cumulatively make a large difference in productivity.  One of the areas where WebObjects really shines is in giving you the ability to graphically connect your data with the view.  You can still do everything manually in code, but the graphical tools give you the ability to really think about the problem on a  level that is much closer to the user experience.</p>
<ul>
<li><a href="http://www.darcynorman.net/2005/03/31/ruby-on-rails">Some thoughts on how Ruby is Similiar to Webobjects</a></li>
<li><a href="http://raibledesigns.com/page/rd?anchor=facets_of_ruby_by_dave">A look at some of the frameworks available for Ruby</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/53/why-java-wont-get-it-right/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thread.sleep() problem</title>
		<link>http://blog.markwshead.com/39/threadsleep-problem/</link>
		<comments>http://blog.markwshead.com/39/threadsleep-problem/#comments</comments>
		<pubDate>Sun, 03 Apr 2005 04:25:22 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/archives/2005/03/05/threadsleep-problem.html</guid>
		<description><![CDATA[The following is a JUnit test that looks like it should always run without a problem. Mark the current time in a variable called start call Thread.sleep and tell it to sleep for x number of seconds, note the current time again in a variable called end and then assert that end - start is [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The following is a JUnit test that looks like it should always run without a problem.  Mark the current time in a variable called <code>start</code> call Thread.sleep and tell it to sleep for x number of seconds, note the current time again in a variable called <code>end</code> and then assert that <code>end - start</code> is going to be less than or equal to x.</p>
<blockquote><pre><code>
    public void testThreadSleep() throws Exception {
        long start = 0;
        long end = 0;
        long elapsedTime = 0;
        for(int i = 1000; i < 1500 ; i = i + 20){
            start = System.currentTimeMillis();
            Thread.sleep(i);
            end = System.currentTimeMillis();
            assertTrue(i <= end - start);
        }
    }
</code></code></pre>
</blockquote>
<p>However in acutally running this code the assertion is not always true. It appears that when you try to call <code>Thread.sleep(x)</code> it may not sleep for the entire <code>x</code> milliseconds.  Obviously it might take <i>longer</i> than <code>x</code> because a thread isn&#8217;t guaranteed to run.  There might be another thread with a higher priority or the system might be doing garbage collection.  However I would expect that it wouldn&#8217;t run <i>less</i> than the specified amount of time, but that is what appears to be happening.</p>
<p>I believe this has to do with the way that the JVM operates.  Evidently it may wake up a thread a few milliseconds before the appointed time.  It is possible that it may be anticipating garbage collection and waking threads up slightly early</p>
<h4>People Found This When Looking For:</h4><ul><li>thead sleep garbage collection (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/39/threadsleep-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entry Level Java Certification (SCJA)</title>
		<link>http://blog.markwshead.com/52/entry-level-java-certification-scja/</link>
		<comments>http://blog.markwshead.com/52/entry-level-java-certification-scja/#comments</comments>
		<pubDate>Wed, 30 Mar 2005 02:06:02 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/archives/2005/03/29/entry-level-java-certification-scja.html</guid>
		<description><![CDATA[According to some posts on Java Ranch, Sun is looking to create a Sun Certified Java Associates exam. The idea is to have an exam that companies can use to certify entry level programmers. I&#8217;m not sure why this is better than the current Sun Certified Java Programmer certification. It sounds like they want a [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>According to some posts on Java Ranch, Sun is looking to create a Sun Certified Java Associates exam.  The idea is to have an exam that companies can use to certify entry level programmers.  I&#8217;m not sure why this is better than the current Sun Certified Java Programmer certification.  It sounds like they want a certification that is easier to pass for someone with less experience.  I didn&#8217;t find the SCJP exam all that difficult.  In fact I didn&#8217;t even bother to put it on my resume, but after reading all the comments at Java Ranch about how difficult it is to pass maybe I should.<br />
<span id="more-52"></span><br />
This seems like an odd move on Sun&#8217;s part.  Generally most companies aren&#8217;t complaining that the programmers they hire are overqualified.  I suppose it may help them find promising junior programmers who they can mentor.  The exam could help separate people who have a good foundational understanding of the language from those that have only played around with a few features.  I suppose it makes sense from a financial stand point.  The tests aren&#8217;t cheap.</p>
<p>I know that many scripting language programmers are trying to learn Java or C# as their next career step.  If you&#8217;ve only worked with a scripting language, the transition to object oriented anything is going to be a big step.  Trying to understand threads, nested classes, etc. when you are still trying to transition away from thinking of everything as a web page with code snippets can be a pretty big challenge.  The new exam could help give these people their first real &#8220;win&#8221; in the Java language.  Sun may see this more as a marketing tactic to help bring people to Java that might be considering C#.  Once someone passes the SCJA they are probably going to want to move up to the SCJP.</p>
<p>At least in my case the Sun Certified Java Developer didn&#8217;t hold a lot of appeal for me once I passed the programmer exam.  I figured that I&#8217;d rather spend my time creating something that I want to use instead of designing an application that is only going to be used as part of the certification process.  It is a lot easier to code something you actually find interesting than something you plan to throw away.</p>
<ul>
<li><a href="http://thedeveloper.blogspot.com/2005/03/new-java-certification-exam-scja.html">Short Comment on new exam</a></li>
<li><a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&#038;f=24&#038;t=026599">Java Ranch Discussion of Exam</a></li>
</ul>
<h4>People Found This When Looking For:</h4><ul><li>resume scja (6)</li><li>scja blogs (2)</li><li>SCJA buy cheap (1)</li><li>SCJA CERTIFIED PEOPLE RESUME (1)</li><li>scja difficult (1)</li><li>scja help (1)</li><li>scja resume (1)</li><li>SCJA resume logo (1)</li><li>scja what do i bring (1)</li><li>cheap java certification (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/52/entry-level-java-certification-scja/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparable vs. Equals</title>
		<link>http://blog.markwshead.com/49/comparable-vs-equals/</link>
		<comments>http://blog.markwshead.com/49/comparable-vs-equals/#comments</comments>
		<pubDate>Sun, 27 Mar 2005 22:13:18 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/archives/2005/03/27/comparable-vs-equals.html</guid>
		<description><![CDATA[Agylen: Comparable vs equals has a nice discussion of how compareTo is used in Sets. If you don&#8217;t understand how Java is going to use your compareTo and your equals methods you can run into a problem with Sets. Basically you shouldn&#8217;t have a compareTo() method that returns 0 unless equals() returns true. Since a [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://agylen.com/blojsom/blog/devel/?permalink=Comparable_vs_equals.txt">Agylen: Comparable vs equals</a> has a nice discussion of how compareTo is used in Sets.</p>
<p>If you don&#8217;t understand how Java is going to use your compareTo and your equals methods you can run into a problem with Sets.  Basically you shouldn&#8217;t have a <code>compareTo()</code> method that returns 0 unless <code>equals()</code> returns <code>true</code>.</p>
<p>Since a Set only allows once instance of each object, it will ignore the addition of any objects it already contains.  If your object implements the <code>Comparator</code> interface the Set will check the compareTo method not the equals method.</p>
<p>It is common to write compareTo methods that only look at one field.  For example, you might want to sort Person objects by their last name and then first name.  If you only check the last and first name field, then comparing two John Smiths would return 0 even if they were different objects.  This would cause the Set to evaluate them as the same object and prevent you from adding the second John Smith to the Set.</p>
<h4>People Found This When Looking For:</h4><ul><li>compareto vs equals (6)</li><li>java compareTo vs equals (5)</li><li>java equals vs compareto (4)</li><li>java comparable vs equals (3)</li><li>equals vs compareto in java (2)</li><li>equals vs compare in java (1)</li><li>java Comparable equals (1)</li><li>comparable and equals (1)</li><li>java comparator equels (1)</li><li>java comparator vs comparable (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/49/comparable-vs-equals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ONJava.com: Using JUnit With Eclipse IDE</title>
		<link>http://blog.markwshead.com/38/onjavacom-using-junit-with-eclipse-ide/</link>
		<comments>http://blog.markwshead.com/38/onjavacom-using-junit-with-eclipse-ide/#comments</comments>
		<pubDate>Thu, 24 Feb 2005 01:21:48 +0000</pubDate>
		<dc:creator>Mark Shead</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.markwshead.com/archives/2005/02/23/onjavacom-using-junit-with-eclipse-ide.html</guid>
		<description><![CDATA[Using JUnit With Eclipse IDE is a great simple tutorial on how to use JUnit in Eclipse. It doesn&#8217;t assume any knowledge of JUnit, but is useful as a quick tutorial for people wanting to make a switch to the Eclipse development environment. People Found This When Looking For:eclipse ide genetic algorithms (1)junit eclipse ide [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.onjava.com/pub/a/onjava/2004/02/04/juie.html">Using JUnit With Eclipse IDE</a> is a great simple tutorial on how to use JUnit in Eclipse.  It doesn&#8217;t assume any knowledge of JUnit, but is useful as a quick tutorial for people wanting to make a switch to the Eclipse development environment.</p>
<h4>People Found This When Looking For:</h4><ul><li>eclipse ide genetic algorithms (1)</li><li>junit eclipse ide (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.markwshead.com/38/onjavacom-using-junit-with-eclipse-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

