<?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>Unlikely Teacher &#187; Programming</title>
	<atom:link href="http://unlikelyteacher.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://unlikelyteacher.com</link>
	<description>1. Share Everything* [Programming Gotchas, Technology News, Insights on Living and Everything in Between]</description>
	<lastBuildDate>Fri, 10 Sep 2010 02:59:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Time Unit Conversion in Java</title>
		<link>http://unlikelyteacher.com/2008/03/28/time-unit-conversion-in-java/</link>
		<comments>http://unlikelyteacher.com/2008/03/28/time-unit-conversion-in-java/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 06:39:41 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dayg.wordpress.com/?p=56</guid>
		<description><![CDATA[Ever needed a utility which converts from one unit of time to another? Well with Java 5 and higher, you won&#8217;t have to create your own conversion routine any longer. Say for example you wanted to specify a value in seconds but the method you need to call expects a value in milliseconds (which is [...]]]></description>
			<content:encoded><![CDATA[<p>Ever needed a utility which converts from one unit of time to another?</p>
<p>Well with Java 5 and higher, you won&#8217;t have to create your own conversion routine any longer.</p>
<p>Say for example you wanted to  specify a value in seconds but the method you need to call expects a value in milliseconds (which is a common thing in Java).</p>
<p>Then this would be how you can convert the value with the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/TimeUnit.html#toSeconds(long)" target="_blank">java.util.concurrent.TimeUnit</a> utility.</p>
<pre class="brush: java">

long oneMinute = TimeUnit.SECONDS.toMillis(60);</pre>
<p>Java 5&#8242;s <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/TimeUnit.html#toSeconds(long)" target="_blank">TimeUnit</a> supports conversion to and from nano, micro, milli and seconds while Java 6&#8242;s <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html" target="_blank">TimeUnit</a> also supports  minutes, hours and days.</p>
]]></content:encoded>
			<wfw:commentRss>http://unlikelyteacher.com/2008/03/28/time-unit-conversion-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java vs C# &#8211; switch statements</title>
		<link>http://unlikelyteacher.com/2008/03/19/java-vs-c-switch-statements/</link>
		<comments>http://unlikelyteacher.com/2008/03/19/java-vs-c-switch-statements/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 11:17:29 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Dotnet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dayg.wordpress.com/?p=34</guid>
		<description><![CDATA[This is my first installment of a new blog series I&#8217;m planning to call Java vs C#. Today, I&#8217;ll be discussing the behavior of &#8220;switch&#8221; statements in both Java and C#. Consider this snippet for Java which prints out the values &#8220;1&#8243;, &#8220;2&#8243; and &#8220;Default&#8221; when value = 1. Since I did not add &#8220;break&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>This is my first installment of a new blog series I&#8217;m planning to call <strong>Java vs C#</strong>.</p>
<p>Today, I&#8217;ll be discussing the behavior of &#8220;switch&#8221; statements in both Java and C#.</p>
<p>Consider this snippet for Java which prints out the values &#8220;1&#8243;, &#8220;2&#8243; and &#8220;Default&#8221; when value = 1.</p>
<p>Since I did not add &#8220;break&#8221; statements after each case, it should execute the code in the next cases up to the point where it reaches a break statement (or exits the switch).</p>
<pre class="brush: java">
switch (value) {
   case 1:
      System.out.println(&quot;1&quot;);
   case 2:
      System.out.println(&quot;2&quot;);
   default:
      System.out.println(&quot;Default&quot;);
      break;
}</pre>
<p>You would think that the snippet for C# below (which is patterned after the code above) would behave in exactly the same way.</p>
<pre class="brush: java">
switch (value)
{
   case 1: System.Console.WriteLine(&quot;1&quot;);
   case 2: System.Console.WriteLine(&quot;2&quot;);
   default: System.Console.WriteLine(&quot;Default&quot;);
      break;
}</pre>
<p>But this is where it gets interesting, the code above will actually NOT compile.</p>
<blockquote><p>Error	1	Control cannot fall through from one case label (&#8216;case 1:&#8217;) to another<br />
Error	2	Control cannot fall through from one case label (&#8216;case 2:&#8217;) to another</p></blockquote>
<p>They said that this is actually a safety mechanism for C# which help prevent debugging nightmares for developers in the event that these switch statements get bigger and more complex.</p>
<p>Seems like a valid point.</p>
<p>But it might be important to note that C# still allow fall through for switch statements, provided you do not add any logic to the case statements.</p>
<pre class="brush: java">
switch (value)
{
   case 1:
   case 2:
   default: System.Console.WriteLine(&quot;Default&quot;);
      break;
}</pre>
<p>You can however work around the said fall through problem by using <a href="http://msdn2.microsoft.com/en-us/library/13940fs2.aspx" target="_blank">goto</a> which I do not really recommend (so I&#8217;m not going to add any more details about that).</p>
<p>As a side note, in addition to int and enum types, C# switch statements also allow <a href="http://msdn2.microsoft.com/en-us/library/362314fe.aspx" target="_blank">string</a> types as argument.</p>
<p>So there you have it folks, switch statements in Java and C#.</p>
<p>Hope you enjoyed and learned something from my first installment.</p>
<p>References:</p>
<ul>
<li><a href="http://www.amazon.com/gp/product/1590598733/102-6566653-3672160?ie=UTF8&amp;tag=doasyogo-20&amp;linkCode=xm2&amp;camp=1789&amp;creativeASIN=1590598733" target="_blank">Accelerated C# 2008</a></li>
<li><a href="http://www.amazon.com/gp/product/1590598849/102-6566653-3672160?ie=UTF8&amp;tag=doasyogo-20&amp;linkCode=xm2&amp;camp=1789&amp;creativeASIN=1590598849" target="_blank">Pro C# 2008 and the .NET 3.5 Platform</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://unlikelyteacher.com/2008/03/19/java-vs-c-switch-statements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Content Assist / Code Completion problem with Eclipse and Netbeans</title>
		<link>http://unlikelyteacher.com/2008/02/27/content-assist-code-completion-problem-with-eclipse-and-netbeans/</link>
		<comments>http://unlikelyteacher.com/2008/02/27/content-assist-code-completion-problem-with-eclipse-and-netbeans/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 09:50:46 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[IntelliJ IDEA]]></category>
		<category><![CDATA[Logitech Quickcam]]></category>
		<category><![CDATA[Netbeans]]></category>

		<guid isPermaLink="false">http://dayg.wordpress.com/?p=33</guid>
		<description><![CDATA[I&#8217;ve had the weirdest problem the other day. It was the first time I went back to using our DELL E1405 after being very comfortable with my company issued D620 (which I now had to surrender to my former employer). Everything was working well until I noticed a simple but very annoying problem: CTRL+SPACE for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had the weirdest problem the other day. It was the first time I went back to using our <a href="http://www.amazon.com/gp/product/B0013EMVGS/104-5414965-3027118?ie=UTF8&amp;tag=doasyogo-20&amp;linkCode=xm2&amp;camp=1789&amp;creativeASIN=B0013EMVGS" target="_blank">DELL E1405</a> after being very comfortable with my company issued D620 (which I now had to surrender to my former employer). Everything was working well until I noticed a simple but very annoying problem:</p>
<p>CTRL+SPACE for Eclipse was not working!</p>
<p>I tried playing with the configuration, resetting everything to defaults, removing the <a title="Building Commercial-Quality Plug-ins" href="http://www.amazon.com/gp/product/032142672X/104-5414965-3027118?ie=UTF8&amp;tag=doasyogo-20&amp;linkCode=xm2&amp;camp=1789&amp;creativeASIN=032142672X" target="_blank">plugins</a> one by one. Nothing seemed to work. I tried a fresh copy and even got to the point of installing Netbeans. And guess what, CTRL+SPACE did not work for Netbeans either!</p>
<p>Which lead me to the conclusion that there must be something else causing the problem. I tried killing all the unnecessary processes one by one and got to the bottom of the problem.</p>
<p>It was the Logitech Quickcam v10 application. Unfortunately, I didn&#8217;t have internet connection at home which explains why I had to figure out the problem all by myself.</p>
<p>I tried searching the net when I got to the office and saw some posts that v11 of the application already fixes the problem.</p>
<p>What a relief!</p>
]]></content:encoded>
			<wfw:commentRss>http://unlikelyteacher.com/2008/02/27/content-assist-code-completion-problem-with-eclipse-and-netbeans/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
