<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Technical Musings !!</title>
	<atom:link href="http://kamleshkr.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kamleshkr.wordpress.com</link>
	<description>Kamlesh&#039;s learning and rendezvous with the technical world</description>
	<lastBuildDate>Sat, 26 Nov 2011 01:27:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='kamleshkr.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/8d59d9ecf8076e4487fb2aee4557ef28?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Technical Musings !!</title>
		<link>http://kamleshkr.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://kamleshkr.wordpress.com/osd.xml" title="Technical Musings !!" />
	<atom:link rel='hub' href='http://kamleshkr.wordpress.com/?pushpress=hub'/>
		<item>
		<title>JSP: Problem Using Spring Message with JSTL</title>
		<link>http://kamleshkr.wordpress.com/2011/11/26/jsp-problem-using-spring-message-with-jstl/</link>
		<comments>http://kamleshkr.wordpress.com/2011/11/26/jsp-problem-using-spring-message-with-jstl/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 01:14:01 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[spring]]></category>
		<category><![CDATA[c:set]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[JSTL]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring Message]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=293</guid>
		<description><![CDATA[Couple of days back I was trying to externalize the labels and messages in a JSP file to a property file. As I was using Spring MVC, decided to use &#60;spring:message&#62; tag to achieve this. Everything else worked fine except when I used &#60;spring:message&#62; tag as a value attribute of &#60;c:set&#62;. Albeit it sounds very [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=293&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Couple of days back I was trying to externalize the labels and messages in a JSP file to a property file. As I was using Spring MVC, decided to use &lt;spring:message&gt; tag to achieve this. Everything else worked fine except when I used &lt;spring:message&gt; tag as a value attribute of &lt;c:set&gt;. Albeit it sounds very simple, I had to spend some time finding out the way. And hence considering this a candidate for my blog.</p>
<p><strong>Problem:</strong></p>
<p>Unable to use &lt;spring:message&gt; tag with the JSTL  &lt;c:set&gt; tag like below:</p>
<p>&lt;c:set var=&#8221;someVar&#8221; value=&#8221;&lt;spring:message code=&#8217;some.value&#8217;/&gt;&#8221; /&gt;</p>
<p><strong>Solution:</strong><br />
Nest the &lt;spring:message&gt; tag in the JSTL tag.</p>
<p>&lt;c:set var=&#8221;someVar&#8221;&gt;<br />
&lt;spring:message code=&#8221;some.value&#8221;/&gt;<br />
&lt;/c:set&gt;</p>
<p>Enjoy Learning,<br />
Kamlesh</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/j2ee/spring-j2ee/'>spring</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/293/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=293&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2011/11/26/jsp-problem-using-spring-message-with-jstl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Inside Java: Concurrent modification when using collection and iterator</title>
		<link>http://kamleshkr.wordpress.com/2011/03/26/inside-java-concurrent-modification-when-using-collection-and-iterator/</link>
		<comments>http://kamleshkr.wordpress.com/2011/03/26/inside-java-concurrent-modification-when-using-collection-and-iterator/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 00:30:57 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[AbstractList]]></category>
		<category><![CDATA[concurrentModificationException]]></category>
		<category><![CDATA[expectedModCount]]></category>
		<category><![CDATA[Iterator]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[modCount]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=271</guid>
		<description><![CDATA[This article explains how java detects concurrentModificationException in case of a collection like List.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=271&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><tt>ConcurrentModificationException</tt> may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible. This exception is encountered more often in case of collections when one thread is iterating over the collection and other tries to modify it.</p>
<p>This article explains how java detects concurrent modifications to a List with the help of an example. The comments provided along with the code are self explanatory so let us go through the example first:</p>
<p><strong><span style="text-decoration:underline;">ConcurrentModificationTest.java</span></strong></p>
<p><code>package com.technicalmusings.examples.collection;</code></p>
<p><code>import java.util.Iterator;<br />
import java.util.LinkedList;<br />
import java.util.List;</code></p>
<p><code>/**<br />
* The class explains how concurrent modification is detected in List.<br />
*/<br />
</code><br />
<code>public class ConcurrentModificationTest {<br />
</code><br />
<code>public static void main(String[] args) {</code></p>
<p><code>// Instantiating the list sets the modCount field of list to 0<br />
// modCount is a protected integer variable defined in the AbstractList class.<br />
</code><br />
<code>List&lt;Object&gt; myList = new LinkedList&lt;Object&gt;();<br />
</code><br />
<code>myList.add(new Object()); // modCount incremented to 1<br />
myList.add(new Object()); // modCount incremented to 2<br />
myList.add(new Object()); // modCount incremented to 3</code></p>
<p><code>// Getting an iterator sets the value of expectedModCount field<br />
// equal to that of the modCount field of list.<br />
</code><br />
<code>Iterator&lt;Object&gt; itr1 = myList.iterator(); //itr1: expectedModCount = 3<br />
Iterator&lt;Object&gt; itr2 = myList.iterator(); //itr2: expectedModCount = 3</code></p>
<p><code>// The first Iterator traverses the list once<br />
itr1.next();</code></p>
<p><code>// The second iterator traverses and removes the first element<br />
itr2.next();<br />
itr2.remove();<br />
// In the previous step Itr2 modifies the list and sets the<br />
// expectedModCount field to 4. The modCount field of the list<br />
// has also been now incremented to 4<br />
</code><br />
<code>// The first iterator again tries to traverse the list<br />
itr1.next();<br />
</code><br />
<code>// java.util.ConcurrentModificationException is thrown at this stage<br />
// because itr1 finds its expectedModCount (which is still 3) to be not<br />
// matching with the modCount field of the list<br />
}<br />
}</code></p>
<p>The <tt>ConcurrentModificationTest.java</tt> class shown above explains how java works behind the scenes to detect concurrent modification and throw the <tt>ConcurrentModificationException</tt> in case of a List. List has an integer field <tt>modCount</tt>, which is incremented each time a structural modification is done in the list. Structural modification includes methods like add, remove, clear etc. The Iterator on the other hand uses another integer field, <tt>expectedModCount</tt>, to take care of concurrent modifications in the list. Iterator expects both the variables <tt>modCount</tt> and <tt>expectedModCount</tt> to be the same. In case the list is modified by any other means the <tt>modCount</tt> and <tt>expectedModCount</tt> differs and the exception is thrown.</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/java/'>JAVA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=271&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2011/03/26/inside-java-concurrent-modification-when-using-collection-and-iterator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Threads: Thread and Exception Handling</title>
		<link>http://kamleshkr.wordpress.com/2011/03/24/java-threads-thread-and-exception-handling/</link>
		<comments>http://kamleshkr.wordpress.com/2011/03/24/java-threads-thread-and-exception-handling/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 07:12:40 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[exception handling in thread]]></category>
		<category><![CDATA[java thread]]></category>
		<category><![CDATA[ThreadGroup]]></category>
		<category><![CDATA[uncaughtException method]]></category>
		<category><![CDATA[UncaughtExceptionHandler]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=255</guid>
		<description><![CDATA[The post explains how to handle uncaught exceptions in a thread.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=255&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Whenever an uncaught exception occurs in a thread&#8217;s run method we get a default exception dump which gets printed on <tt>System.err</tt> stream. We may not always want to live with this default behavior and might think about logging the exception message in a more sophisticated way or doing something else as per business requirement.</p>
<p>Such custom exception handling can be achieved using the <tt>UncaughtExceptionHandler</tt> interface of the <tt>Thread</tt> class. The <tt>ThreadGroup</tt> class also implements the <tt>Thread</tt>.<tt>UncaughtExceptionHandler</tt> interface. The interface has only one method defined, which is:</p>
<p><tt> <strong>void uncaughtException(Thread t, Throwable e);</strong></tt></p>
<p>This handler interface is invoked when a thread abruptly terminates due to an uncaught exception. The below excerpt from Java documentation explains the <tt>UncaughtExceptionHandler</tt> interface:</p>
<blockquote><p>When a thread is about to terminate due to an uncaught exception the Java Virtual Machine will query the thread for its <tt>UncaughtExceptionHandler</tt> using <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html#getUncaughtExceptionHandler%28%29"><code>Thread.getUncaughtExceptionHandler()</code></a> and will invoke the handler&#8217;s <tt>uncaughtException</tt> method, passing the thread and the exception as arguments. If a thread has not had its <tt>UncaughtExceptionHandler</tt> explicitly set, then its <tt>ThreadGroup</tt> object acts as its <tt>UncaughtExceptionHandler</tt>. If the <tt>ThreadGroup</tt> object has no special requirements for dealing with the exception, it can forward the invocation to the <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html#getDefaultUncaughtExceptionHandler%28%29">default uncaught exception handler</a>.</p></blockquote>
<p>Thread class has two methods viz. <tt>setDefaultUncaughtExceptionHandler()</tt> and <tt>setUncaughtExceptionHandler()</tt>. The <tt>setDefaultUncaughtExceptionHandler()</tt> which is a static method of <tt>Thread</tt> class can be used to provide a common exception handler for all the threads. On the other hand <tt>setUncaughtExceptionHandler()</tt> is a non static method of <tt>Thread</tt> class which is used to provide handler to a given thread.</p>
<p>The below example shows how to handle the uncaught exception thrown from a Thread:</p>
<p><strong><span style="text-decoration:underline;">MyThreadTest.java</span></strong></p>
<p><code><strong>package</strong> com.technicalmusings.examples.thread;</code></p>
<p><code>/**<br />
* The below class creates a thread which is supposed to throw an exception.</code><br />
<code>* A handler is added to the thread before calling the start method of thread.</code><br />
<code>* When the thread executes the exception is handled by the handler</code><br />
<code>* and the custom exception message is displayed on the console.<br />
*/</code></p>
<p><code><strong>public</strong> <strong>class</strong> MyThreadTest {</code></p>
<p><code><strong>public</strong> <strong>static</strong> </code><code><strong>void</strong> main(String[] args) {</code></p>
<p><code> Thread newThread = <strong>new</strong> </code><code>Thread(<strong>new</strong> ThreadWithException());</code></p>
<p><code> // Add the handler to the thread object<br />
newThread.setUncaughtExceptionHandler(<strong>new </strong>Thread.UncaughtExceptionHandler(){<br />
</code><br />
<code>@Override<br />
<strong>public</strong> <strong>void</strong> uncaughtException(Thread t, Throwable e) {</code></p>
<p><code> System.<em>out</em>.println("ERROR! An exception occurred in " + t.getName() + ". Cause: " + e.getMessage());<br />
}<br />
});</code></p>
<p><code>newThread.start();<br />
}<br />
}</code></p>
<p><code>/**<br />
* This thread throws a custom exception in its run method.<br />
*/</code></p>
<p><code><strong>class</strong> ThreadWithException <strong>implements</strong> Runnable {</code></p>
<p><code>@Override<br />
<strong>public</strong> <strong>void</strong> run() {<br />
<strong>throw</strong> <strong>new</strong> RuntimeException("Application Specific Exception!!");<br />
}<br />
}</code></p>
<p><strong><span style="text-decoration:underline;">Output</span>:</strong></p>
<p><code>ERROR! An exception occurred in Thread-0. Cause: Application Specific Exception!!</code></p>
<p>Enjoy Learning,<br />
Kamlesh</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/java/'>JAVA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/255/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=255&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2011/03/24/java-threads-thread-and-exception-handling/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
		<item>
		<title>We’ve always done it that way</title>
		<link>http://kamleshkr.wordpress.com/2011/01/21/we%e2%80%99ve-always-done-it-that-way/</link>
		<comments>http://kamleshkr.wordpress.com/2011/01/21/we%e2%80%99ve-always-done-it-that-way/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 00:58:36 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=250</guid>
		<description><![CDATA[We’ve always done it that way. How many times you have heard this punch line and how many times implemented the same in your work or life? Sounds like a Déjà vu, isn’t it? In the book Code Complete 2, Steve McConnell has referred to a very nice story to emphasis that we should not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=250&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We’ve always done it that way.</p>
<p>How many times you have heard this punch line and how many times implemented the same in your work or life? Sounds like a Déjà vu, isn’t it?</p>
<p>In the book Code Complete 2, Steve McConnell has referred to a very nice story to emphasis that we should not always adhere to the above line. The story goes as below:</p>
<p>Beth wanted to cook a pot roast according to an award-winning pot roast recipe handed down in her husband’s family. Her husband, Abdul, said that his mother had taught him to sprinkle it with salt and pepper, cut both ends off, put it in the pan, cover it, and cook it. Beth asked, “Why do you cut both ends off?” Abdul said, “I don’t know. I’ve always done it that way. Let me ask my mother.” He called her, and she said, “I don’t know. I’ve always done it that way. Let me ask your grandmother.” She called his grandmother, who said, “I don’t know why you do it that way. I did it that way because it was too big to fit in my pan.</p>
<p>Cheers,</p>
<p>Kamlesh</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/general/'>General</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/250/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=250&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2011/01/21/we%e2%80%99ve-always-done-it-that-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
		<item>
		<title>2010 in review</title>
		<link>http://kamleshkr.wordpress.com/2011/01/04/2010-in-review/</link>
		<comments>http://kamleshkr.wordpress.com/2011/01/04/2010-in-review/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 00:30:50 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[JAVA]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=247</guid>
		<description><![CDATA[The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health: The Blog-Health-o-Meter™ reads Wow. Crunchy numbers A helper monkey made this abstract painting, inspired by your stats. A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=247&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health:</p>
<p><img style="border:1px solid #ddd;background:#f5f5f5;padding:20px;" src="http://s0.wp.com/i/annual-recap/meter-healthy5.gif" alt="Healthy blog!" width="250" height="183" /></p>
<p>The <em>Blog-Health-o-Meter™</em> reads Wow.</p>
<h2>Crunchy numbers</h2>
<div style="width:288px;float:right;border:1px solid #ddd;background:#fff;margin:0 0 1em 1em;padding:6px;">
<p><img src="http://s0.wp.com/i/annual-recap/abstract-stats-5.png" alt="Featured image" /></p>
<p><em>A helper monkey made this abstract painting, inspired by your stats.</em></p>
</div>
<p>A Boeing 747-400 passenger jet can hold 416 passengers.  This blog was viewed about <strong>7,300</strong> times in 2010.  That&#8217;s about 18 full 747s.</p>
<p>&nbsp;</p>
<p>In 2010, there were <strong>7</strong> new posts, growing the total archive of this blog to 24 posts. There were <strong>11</strong> pictures uploaded, taking up a total of 490kb. That&#8217;s about a picture per month.</p>
<p>The busiest day of the year was May 17th with <strong>1,076</strong> views. The most popular post that day was <a style="color:#08c;" href="http://kamleshkr.wordpress.com/2010/02/17/inside-java-arrays-aslistt-a/">Inside Java: Arrays.asList(T&#8230; a)</a>.</p>
<h2>Where did they come from?</h2>
<p>The top referring sites in 2010 were <strong>dzone.com</strong>, <strong>stumbleupon.com</strong>, <strong>google.co.in</strong>, <strong>google.com</strong>, and <strong>shiman.wordpress.com</strong>.</p>
<p>Some visitors came searching, mostly for <strong>java arrays.aslist</strong>, <strong>arrays.aslist</strong>, <strong>java callable</strong>, <strong>java aslist</strong>, and <strong>kamlesh java</strong>.</p>
<h2>Attractions in 2010</h2>
<p>These are the posts and pages that got the most views in 2010.</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">1</div>
<p><a style="margin-right:10px;" href="http://kamleshkr.wordpress.com/2010/02/17/inside-java-arrays-aslistt-a/">Inside Java: Arrays.asList(T&#8230; a)</a> <span style="color:#999;font-size:8pt;">February 2010</span><br />
8 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">2</div>
<p><a style="margin-right:10px;" href="http://kamleshkr.wordpress.com/2007/07/23/what-is-time-complexity-of-an-algorithm-o-notation/">What is Time Complexity of An algorithm? : (O-notation)</a> <span style="color:#999;font-size:8pt;">July 2007</span><br />
4 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">3</div>
<p><a style="margin-right:10px;" href="http://kamleshkr.wordpress.com/2009/10/02/java-threads-callable-and-future/">Java Threads : Callable and Future</a> <span style="color:#999;font-size:8pt;">October 2009</span><br />
3 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">4</div>
<p><a style="margin-right:10px;" href="http://kamleshkr.wordpress.com/2010/02/08/axis2-creating-and-consuming-a-web-service/">Axis2: Creating and consuming a web service</a> <span style="color:#999;font-size:8pt;">February 2010</span><br />
1 comment</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">5</div>
<p><a style="margin-right:10px;" href="http://kamleshkr.wordpress.com/2010/04/23/java-interview-checklist/">Java Interview: Checklist</a> <span style="color:#999;font-size:8pt;">April 2010</span><br />
5 comments</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/java/'>JAVA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=247&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2011/01/04/2010-in-review/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/meter-healthy5.gif" medium="image">
			<media:title type="html">Healthy blog!</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/abstract-stats-5.png" medium="image">
			<media:title type="html">Featured image</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting API in Java: Invoking JavaScript from Java</title>
		<link>http://kamleshkr.wordpress.com/2010/05/09/scripting-api-in-java-invoking-javascript-from-java/</link>
		<comments>http://kamleshkr.wordpress.com/2010/05/09/scripting-api-in-java-invoking-javascript-from-java/#comments</comments>
		<pubDate>Sun, 09 May 2010 02:24:28 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[javax.script.*]]></category>
		<category><![CDATA[Mozilla Rhino in Java]]></category>
		<category><![CDATA[using JavaScript variable in Java]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=230</guid>
		<description><![CDATA[Scripting languages like JavaScript sometimes prove to be more flexible over the normal Java code. The Scripting API (javax.script.*) introduced in Java 6 allows to use the advantage of JavaScript in Java. With the help of a Scripting Engine, the Scripting API can invoke scripts in the Java code. Java 6 comes with an implementation [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=230&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Scripting languages like JavaScript sometimes prove to be more flexible over the normal Java code. The Scripting API (javax.script.*) introduced in Java 6 allows to use the advantage of JavaScript in Java.</p>
<p>With the help of a Scripting Engine, the Scripting API can invoke scripts in the Java code. Java 6 comes with an implementation of JavaScript interpreter by Mozilla, <strong>Rhino</strong>. Scripting engines for other scripting languages can be found at <a href="http://scripting.dev.java.net/">http://scripting.dev.java.net</a>.</p>
<p>Let us see an example of how to invoke JavaScript from a Java class.</p>
<pre><code><strong>package</strong> com.technicalmusings.sample.js;
<strong>import</strong> java.util.List;
<strong>import</strong> javax.script.Invocable;
<strong>import</strong> javax.script.ScriptEngine;
<strong>import</strong> javax.script.ScriptEngineFactory;
<strong>import</strong> javax.script.ScriptEngineManager;
<strong>import</strong> javax.script.ScriptException;

<strong>public</strong> <strong>class</strong> ScriptRunner {

<strong>public</strong> <strong>static</strong> <strong>void</strong> main(String[] args) <strong>throws</strong> Exception{

    //the script manager
    ScriptEngineManager scriptManager = <strong>new</strong> ScriptEngineManager();

    //Check the available script engines
    List&lt;ScriptEngineFactory&gt; scriptFactories = scriptManager.getEngineFactories();

    System.<em>out</em>.println("Available Engines in Java 1.6.0_17:");
    <strong>for</strong> (ScriptEngineFactory factory : scriptFactories){
        System.<em>out</em>.println(factory.getEngineName());
    }
    System.<em>out</em>.println("-----------------------------------");

    System.<em>out</em>.println("Java Script Variables");
    System.<em>out</em>.println("-----------------------------------");

    //Get the java script engine
    ScriptEngine engine = scriptManager.getEngineByName("JavaScript");

    /*
    * USING A JAVASCRIPT VARIABLE:
    * Variables evaluated in JavaScript engine defaults to engine scope.
    * In the below example I am using the method engine.eval(String
    * script) to invoke JavaScript. In case you wish to store JavaScript
    * in a file like abc.js, you can use the overloaded version of the
    * same method which takes a Reader object; engine.eval(Reader
    * reader);
    */

    engine.put("i", 10);
    System.<em>out</em>.println("i * 10 : " + engine.eval("i * 10"));//100
    System.<em>out</em>.println("i : " + engine.eval("i"));//10
    System.<em>out</em>.println("i = i * 10 : " + engine.eval("i = i * 10"));//100
    System.<em>out</em>.println("i : " + engine.eval("i"));//100

    //using javascript variable in java
    <strong>int</strong> i = ((Double)engine.eval("i")).intValue();
    System.<em>out</em>.println("JavaScript variable in Java; i : " + i);
    System.<em>out</em>.println("-----------------------------------");

    /*
    * USING JAVASCRIPT FUNCTION:
    * Script engines provide the feature of invoking a function. In order
    * to be able to invoke a function the script engine must implement
    * the Invocable interface. Following example shows how to use a
    * simple function in JavaScript.
    */

    System.<em>out</em>.println("Java Script Function");
    System.<em>out</em>.println("-----------------------------------");
    //Check whether engine implements Invocable as it depends on the engine’s implementation.
    <strong>if</strong>(engine <strong>instanceof</strong> Invocable){
    //Declare the function
        String functionScript = "function display(message){ return message }";
        engine.eval(functionScript);

        //Invoke the function with a String parameter
        String message = "Hey JS! Greetings from Java";
        Object result = ((Invocable)engine).invokeFunction("display", message);
        System.<em>out</em>.println(result);

        //Invoke the function using a pre defined variable
        result = ((Invocable)engine).invokeFunction("display", "i is " + engine.eval("i"));
        System.<em>out</em>.println(result);
    }
    System.<em>out</em>.println("-----------------------------------");
 }
}

</code></pre>
<p>The output of the above example is given as below:</p>
<p><code>Available Engines in Java 1.6.0_17:</code><br />
<code>Mozilla Rhino</code><br />
<code>-----------------------------------</code><br />
<code>Java Script Variables</code><br />
<code>-----------------------------------</code><br />
<code> </code></p>
<pre>i * 10 : 100.0
i : 10
i = i * 10 : 100.0
i : 100.0
-----------------------------------
Java Script Function
-----------------------------------
Hey JS! Greetings from Java
i is 100.0
-----------------------------------</pre>
<p>I have shown very basic use of the scripting APIs in this post. There are many other features which a scripting engine provides. For example if we require executing a script multiple times we can compile the script once and use that as required. The engine in that case must implement the Compilable interface.</p>
<p>The Scripting API also solved the problem of using a JavaScript variable in java and vice-versa. Most of the times we face this problem in a JSP where we have to use workarounds. Though I still need to test this but this should work. Let me know if you have tested the same.</p>
<p>Enjoy Learning,</p>
<p>Kamlesh</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/java/'>JAVA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/230/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=230&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2010/05/09/scripting-api-in-java-invoking-javascript-from-java/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Interview: Checklist</title>
		<link>http://kamleshkr.wordpress.com/2010/04/23/java-interview-checklist/</link>
		<comments>http://kamleshkr.wordpress.com/2010/04/23/java-interview-checklist/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 02:09:19 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[java important points]]></category>
		<category><![CDATA[java interview preparation]]></category>
		<category><![CDATA[java interview questions]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=225</guid>
		<description><![CDATA[What all is expected in a Java Interview. Facts and keywords of Java.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=225&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am listing below the checklist of concepts and keywords in java which are most frequently asked in interview. Please excuse me for presenting it in a random order.</p>
<p>Following are the topics/keywords/concepts which require a crisp knowledge and understanding. These are basisc only.</p>
<ul>
<li>JVM &#8211; About JVM, JIT compiler, Bytecode, Classloader</li>
<li>Garbage Colection &#8211; Conditions when JVM invokes garbage collection, System.gc()</li>
<li>Static and Instance initializer block</li>
<li>Datatypes &#8211; character especially</li>
<li>enum &#8211; where to declare, defining constructor, methods and variables in enum</li>
<li>OOP concepts &#8211; inheritance, polymorphism, aggregation vs Composition, abstraction</li>
<li>Multiple Inheritance in java</li>
<li>Difference/Similarities between interface and abstract class</li>
<li>Software Engineering Concepts &#8211; Coupling and Cohesion</li>
<li>String, StringBuffer and StringBuilder</li>
<li>Exception Handling &#8211; Checked vs Unchecked Exceptions, Assertion, Error, Exception Hierarchy, throw vs throws</li>
<li>final, finally and finalize</li>
<li>Method Overriding (Rules for the same)</li>
<li>Method Overloading &#8211; Covariant Return (Java5)</li>
<li>Autoboxing</li>
<li>Array &#8211; Declaring an anonymous and multidimensional array</li>
<li>Keywords like super and this</li>
<li>The Object classs &#8211; equals and hashcode methods</li>
<li>Access Specifiers &#8211; default, public , protected and private</li>
<li>Marker Interface, Wrapper Classe and Adapter Class</li>
<li>Classes like Math, StrictMath, Scanner, Console</li>
<li>Java IO: Important classes in IO, NIO.</li>
<li>Reading and writing XMLs in java. Type of parsers &#8211; SAX, DOM and STAX.</li>
<li>Java UI: AWT vs Swing, Different Layouts, Event handling, Calback methods</li>
<li>Serialization, Transient keyword</li>
<li>Multithreading &#8211; Runnable vs Thread, How to write a thread, difference between run and start method.</li>
<li>Java5 Concurrency and advanced threading &#8211; Callable, Future, Executors, Thread pooling, Locks and Conditions</li>
<li>Collection and Generics &#8211; Map, Set and List; Conventional Questions like ArrayList vs Vector, HashTable vs HashMap etc; Comparator and Comparable; Important collection classes.</li>
<li>Methods of java.util.Collections &#8211; Synchronizing a collection, Creating views</li>
<li>JDBC: The JDBC code, Type of JDBC Drivers, Type of Statements, execute, executeUpdate and executeQuery</li>
</ul>
<p>We can discuss these further in case of queries/suggestions. Feel free to comment and add in case I missed something.</p>
<p>Enjoy learning,</p>
<p>Kamlesh</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/java/'>JAVA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=225&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2010/04/23/java-interview-checklist/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Facts: Multiple Inheritance</title>
		<link>http://kamleshkr.wordpress.com/2010/04/16/inside-java-multiple-inheritance/</link>
		<comments>http://kamleshkr.wordpress.com/2010/04/16/inside-java-multiple-inheritance/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 00:36:27 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[implementation inheritance]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[interface inheritance]]></category>
		<category><![CDATA[multiple inheritance]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=216</guid>
		<description><![CDATA[“Does Java Support Multiple Inheritance?” This is one of the most favorite java interview questions. Whenever this question is asked the most common (and sometimes expected) answers are: “No” or “Well! Java does support multiple inheritance but with the interfaces not the classes.” Both the answers are correct and accepted. However we can find a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=216&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>“Does Java Support Multiple Inheritance?” This is one of the most favorite java interview questions.</p>
<p>Whenever this question is asked the most common (and sometimes expected) answers are:</p>
<p>“No” or</p>
<p>“Well! Java does support multiple inheritance but with the interfaces not the classes.”</p>
<p>Both the answers are correct and accepted.</p>
<p>However we can find a better answer of the same question if we go by what the Java Specification has to say:</p>
<blockquote><p>&#8220;<em>Classes support single implementation inheritance, in which the implementation</em></p>
<p><em>of each class is derived from that of a single superclass, and ultimately from</em></p>
<p><em>the class Object.”</em></p></blockquote>
<blockquote><p><em>“Multiple interface inheritance is supported.”</em></p></blockquote>
<p>The term ‘implementation inheritance’ may be confused with the keyword <em>implements</em>, which is incorrect. Implementation inheritance means a class can inherit (using the keyword <em>extends</em>) only one super class.e.g.</p>
<p>Incorrect:<code> public class Derived extends Base1, Base2</code></p>
<p>Correct:  <code>public class Derived extends Base</code></p>
<p>On the other hand Interface Inheritance implies that a class can implement multiple interfaces (using <em>implements</em> keyword) and an interface can extend multiple interfaces (using extends keyword).</p>
<p>Correct: <code>public class Concrete implements A, B</code></p>
<p>Correct: <code>public interface C extends A, B</code></p>
<p>Incorrect: <code>public interface C implements A, B</code></p>
<p>The concept of inheritance differs from that of C++ in order to avoid the classic diamond problem in C++.</p>
<p>Enjoy Learning,<br />
Kamlesh</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/java/'>JAVA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=216&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2010/04/16/inside-java-multiple-inheritance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Inside Java: Arrays.asList(T&#8230; a)</title>
		<link>http://kamleshkr.wordpress.com/2010/02/17/inside-java-arrays-aslistt-a/</link>
		<comments>http://kamleshkr.wordpress.com/2010/02/17/inside-java-arrays-aslistt-a/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 06:02:47 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Arrays.asList]]></category>
		<category><![CDATA[asList]]></category>
		<category><![CDATA[views in java]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=187</guid>
		<description><![CDATA[Read about what happens behind the scene when the Arrays.asList method is used...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=187&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We frequently use asList method of Arrays class to convert an array to a list. In order to use this method properly we need to know what is happening behind the scene. The complete signature of this method is:   </p>
<pre><code>      <span style="color:#888888;">public static<strong> </strong>&lt;T&gt; List&lt;T&gt; asList(T... a)</span></code>
<code> </code></pre>
<p>This method is declared and defined in java.util.Arrays class. The method returns an object of ArrayList class. But here is one difference which we have to note and take care while using this.     </p>
<p>The object being returned does not belong to java.util.ArrayList class rather it belongs to java.util.Arrays$ArrayList class. Surprised! Actually the Arrays class defines an private static inner class named ArrayList. Following is the signature of the ArrayList class:     </p>
<pre><code>      <span style="color:#888888;">private static class ArrayList&lt;E&gt; extends AbstractList&lt;E&gt;implements RandomAccess, </span></code>
<code><span style="color:#888888;">      java.io.Serializable </span></code></pre>
<p> </p>
<p>Now let us see what the difference between the two ArrayList classes is.  </p>
<p>The Arrays$ArrayList class is sometimes refered as the view of java.util.ArrayList or a fixed size list. This class does not override all the methods of AbstractList class. To be more precise, following are the methods it overrides or declares:     </p>
<pre><code>      <span style="color:#888888;">public int size() </span></code><span style="color:#888888;"> 

<code>      public Object[] toArray()</code>

<code>      public &lt;T&gt; T[] toArray(T[] a)</code>

<code>      public E get(int index)</code>

<code>      public E set(int index, E element)</code>

<code>      public int indexOf(Object o)</code>

<code>      public boolean contains(Object o)</code></span></pre>
<p> </p>
<p>Other methods if being called refer to the AbstractList class default implementation.  </p>
<p>For example if we try to call the add or remove method of Arrays$ArrayList class, we will get an UnsupportedOperationException . The reason behind this is the implementation of these methods in the AbstractList class which is:  </p>
<pre><code>      <span style="color:#888888;">public void add(int index, E element) {
                 throw new UnsupportedOperationException();
      }  

      public E remove(int  index) {
                 throw new  UnsupportedOperationException();
      }</span>  </code></pre>
<p> </p>
<p>I hope this clears the understanding of how views are being used in java.</p>
<p>Let us conclude this article with the javadoc comments of Arrays.asList method: </p>
<blockquote><p><em>Returns a fixed-size list backed by the specified array.  (Changes to the returned list &#8220;write through&#8221; to the array.)  This method acts as bridge between array-based and collection-based APIs, in combination with Collection#toArray.  The returned list is serializable and implements RandomAccess.</em></p>
<p><em>This method also provides a convenient way to create a fixed-size list initialized to contain several elements:<br />
<span style="color:#888888;">List&lt;String&gt; stooges = Arrays.asList(&#8220;Larry&#8221;, &#8220;Moe&#8221;, &#8220;Curly&#8221;);</span></em> </p></blockquote>
<p>Enjoy Learning,<br />
Kamlesh</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/java/'>JAVA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=187&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2010/02/17/inside-java-arrays-aslistt-a/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Apache Pivot &#8211; Build RIA in Java</title>
		<link>http://kamleshkr.wordpress.com/2010/02/16/apache-pivot-build-ria-in-java/</link>
		<comments>http://kamleshkr.wordpress.com/2010/02/16/apache-pivot-build-ria-in-java/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 04:11:52 +0000</pubDate>
		<dc:creator>Kamlesh</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[apache pivot]]></category>
		<category><![CDATA[RIA in Java]]></category>

		<guid isPermaLink="false">http://kamleshkr.wordpress.com/?p=178</guid>
		<description><![CDATA[Apache Pivot is an open-source platform for building rich internet applications in Java. It combines the enhanced productivity and usability features of a modern RIA toolkit with the robustness of the Java platform. Pivot applications are written using a combination of Java and XML and can be run either as an applet or as a standalone, optionally offline, desktop application.

<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=178&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was going through Apache&#8217;s web site and I read the news about Apache Pivot. Apache Pivot  is a Java alternative of Adobe Flex/Flash and Microsoft Silverlight.</p>
<p>In December 2009, Pivot has been declared a top-level Apache project and Pivot 1.4 is the latest version which is available for download.</p>
<p>About Pivot, this is what Apache has to say:</p>
<blockquote><p>Apache Pivot is an open-source platform for building rich internet applications in Java. It combines the enhanced productivity and usability features of a modern RIA toolkit with the robustness of the Java platform. Pivot applications are written using a combination of Java and XML and can be run either as an applet or as a standalone, optionally offline, desktop application.</p>
<p>Like other modern development platforms, Pivot provides a comprehensive set of foundation classes that together comprise a &#8220;framework&#8221;. These classes form the building blocks upon which more complex and sophisticated applications can be built.</p></blockquote>
<p>Expolre more about Apache Pivot, <a class="wpGallery" title="Apache Pivot Home Page" href="http://pivot.apache.org/index.html" target="_blank">here</a>.</p>
<p>Enjoy Learning,</p>
<p>Kamlesh</p>
<br />Filed under: <a href='http://kamleshkr.wordpress.com/category/java/'>JAVA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kamleshkr.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kamleshkr.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kamleshkr.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kamleshkr.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kamleshkr.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kamleshkr.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kamleshkr.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kamleshkr.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kamleshkr.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kamleshkr.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kamleshkr.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kamleshkr.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kamleshkr.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kamleshkr.wordpress.com/178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kamleshkr.wordpress.com&amp;blog=9350947&amp;post=178&amp;subd=kamleshkr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kamleshkr.wordpress.com/2010/02/16/apache-pivot-build-ria-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3cfa257e260b5b2255e4197cc050f384?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kamlesh</media:title>
		</media:content>
	</item>
	</channel>
</rss>
