<?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>Kiss Note</title>
	<atom:link href="http://kissnote.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kissnote.com</link>
	<description>Keep IT Simple and Stupid</description>
	<lastBuildDate>Mon, 17 May 2010 17:19:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to reset the root password on Linux</title>
		<link>http://kissnote.com/2010/05/17/how-to-reset-the-root-password-on-linux/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/05/17/how-to-reset-the-root-password-on-linux/#comments</comments>
		<pubDate>Mon, 17 May 2010 17:18:53 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[Tips Everyday]]></category>
		<category><![CDATA[linux tips]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=251</guid>
		<description><![CDATA[Today, i had a big hassle earlier on by accidentally changed my linux password policy and set the expiration for all the password a date before the current time That proves again Monday Morning is always not the most effective day during the week. LOL But i managed to reset the password following this video, [...]]]></description>
			<content:encoded><![CDATA[<p>Today, i had a big hassle earlier on by accidentally changed my linux password policy and set the expiration for all the password a date before the current time <img src='http://kissnote.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  That proves again Monday Morning is always not the most effective day during the week. LOL</p>
<p>But i managed to reset the password following this video, very good one.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/AkENYv7kEhg&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/AkENYv7kEhg&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Put it here in case you guys make the stupid mistake as i did today <img src='http://kissnote.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="http://www.youtube.com/watch?v=AkENYv7kEhg&amp;feature=player_embedded"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/05/17/how-to-reset-the-root-password-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Exception study guide</title>
		<link>http://kissnote.com/2010/04/26/java-exception-study-guide/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/04/26/java-exception-study-guide/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 23:23:26 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=229</guid>
		<description><![CDATA[Checked Exception ParseException eg. DataFormat.parse(String source) : Date, if the source is not good format string like 12/01/2010, it throws this. ClassNotFoundException The forName method in class Class. The findSystemClass method in class ClassLoader . The loadClass method in class ClassLoader. InterruptedException thrown when a thread is waiting, sleeping or pausing. eg. Thread.sleep()/wait()/join()  yield() is [...]]]></description>
			<content:encoded><![CDATA[<h2><strong>Checked Exception</strong></h2>
<p><strong><span style="text-decoration: underline;"><em>ParseException</em></span></strong></p>
<p>eg. DataFormat.parse(String source) : Date, if the source is not good format string like 12/01/2010, it throws this.</p>
<p><strong><span style="text-decoration: underline;"><em>ClassNotFoundException</em></span></strong></p>
<ul>
<li>The <code>forName</code> method in class <code>Class</code>.</li>
<li>The <code>findSystemClass</code> method in class      <code>ClassLoader</code> .</li>
<li>The <code>loadClass</code> method in class <code>ClassLoader</code>.</li>
</ul>
<p><strong><span style="text-decoration: underline;"><em>InterruptedException</em></span></strong> thrown when a thread is waiting,  sleeping or pausing.</p>
<p>eg. Thread.sleep()/wait()/join()  <span style="color: #888888;"><em>yield()</em></span> is not throwing any exception</p>
<h2><strong>Runtime Exception</strong></h2>
<p><strong><span style="text-decoration: underline;"><em>NoSerialzableException</em></span></strong></p>
<p>eg. when one object gets serialized, its attributes are not serialized or its collaborator is not <strong>serializable</strong></p>
<p><strong><span style="text-decoration: underline;"><em>IllegalThreadStateException</em></span></strong> start the same thread more than once</p>
<p><strong><span style="text-decoration: underline;"><em>IllegalMonitorStateException</em></span></strong> wait(),notify(),notifyAll() is not in the synchronized context</p>
<p><strong><span style="text-decoration: underline;"><em>ClassCastException</em></span></strong></p>
<p>eg1.</p>
<p>Object o =  new String(&#8220;jay&#8221;);</p>
<p>Integer i = (Integer)o;</p>
<p>eg.2 adding object of class type not comparable to TreeSet or TreeMap, It fails and throws CCE when it tries to cast the type to Comparable and sort the elements added.</p>
<p>note: this is exactly where it passes the compile time. During the runtime, ref type points to the object it can&#8217;t. ClassCastException gets thrown.</p>
<p><strong><span style="text-decoration: underline;"><em>ArrayIndexOutOfBoundsException </em></span></strong></p>
<p><strong><span style="text-decoration: underline;"><em>IllegalArgumentException</em></span></strong> when method receives an argument formatted differently</p>
<p><strong><span style="text-decoration: underline;"><em>IllegalStateException</em></span></strong> when</p>
<p>eg. matcher.group() is called while there is no match. So that&#8217;s why matcher.group() should always be called in side while(matcher.find())</p>
<p><strong><span style="text-decoration: underline;"><em>NumberFormatException</em></span></strong> NFE</p>
<p>eg. Integer i = new Interger(&#8220;messy&#8221;);</p>
<p><span style="text-decoration: underline;"><em><strong>NullPointException</strong> </em></span></p>
<p><strong><span style="text-decoration: underline;"><em>ClassNotDefException</em></span></strong> Thrown when the JVM can&#8217;t find a class it needs. classpath issue or missing a class file.</p>
<p><strong><em><span style="text-decoration: underline;">ArrayStoreException</span></em></strong> thrown when the object doesn&#8217;t fit in the array type.</p>
<p>eg. B extends A, C extends B</p>
<p>A[] a = new C[1];</p>
<p>a[0] = new B(); pass Compile, throw ASE at runtime. cause B IS NOT an A.</p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/04/26/java-exception-study-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jave Regular Expression study guide</title>
		<link>http://kissnote.com/2010/04/26/jave-regular-expression-study-guide/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/04/26/jave-regular-expression-study-guide/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 21:50:07 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[scjp]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=226</guid>
		<description><![CDATA[Metacharacters: \d : A digit \w : A word char \s : A white space char [] : match one of the char contained in the square bracket Quantifiers: * Zero or more occurrences ? Zero or one occurrence + 1 or more occurrence The Predefined Dot: . any char NOTE: conversion type is used [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Metacharacters</strong></em>:</p>
<p>\d : A digit</p>
<p>\w : A word char</p>
<p>\s : A white space char</p>
<p>[] : match one of the char contained in the square bracket</p>
<p><em><strong>Quantifiers:</strong></em></p>
<p>* Zero or more occurrences</p>
<p>? Zero or one occurrence</p>
<p>+ 1 or more occurrence</p>
<p><em><strong>The Predefined Dot</strong></em>:</p>
<p>. any char</p>
<p><strong>NOTE:</strong></p>
<p><strong>conversion type </strong>is used for formatting <strong>NOT</strong> for regex.</p>
<p>eg. printf(), format() &#8230;</p>
<p>bcdfs</p>
<p>b-boolean, c-char, d-integer, f-float,s-string</p>
<p><strong>escape sequence</strong>:</p>
<p>\n = line feed</p>
<p>\b = backspace</p>
<p>\t = tab</p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/04/26/jave-regular-expression-study-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Assertion Study note</title>
		<link>http://kissnote.com/2010/04/24/java-assertion-study-note/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/04/24/java-assertion-study-note/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 23:44:56 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[scjp]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=220</guid>
		<description><![CDATA[In SCJP exam, You are expected to know appropriate and inappropriate assertions appropriate: 1. Do check private method 2. check code never should be reached inappropriate: 1. check public method 2. check command-line arguments 3. assertion check will bring side affects eg.assert a=a+1 // a&#8217;s value will be varied depending on whether assertion is enabled [...]]]></description>
			<content:encoded><![CDATA[<p>In SCJP exam, You are expected to know <strong>appropriate </strong>and <strong>inappropriate </strong>assertions</p>
<p><strong>appropriate:</strong></p>
<p>1. Do check private method</p>
<p>2. check code never should be reached</p>
<p><strong>inappropriate:</strong></p>
<p>1. check public method</p>
<p>2. check command-line arguments</p>
<p>3. assertion check will bring side affects</p>
<p><span style="color: #888888;">eg.assert a=a+1 // a&#8217;s value will be varied depending on whether assertion is enabled or not. </span></p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/04/24/java-assertion-study-note/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Interface Study note</title>
		<link>http://kissnote.com/2010/04/24/java-interface-study-note/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/04/24/java-interface-study-note/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 22:18:49 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[scjp]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=212</guid>
		<description><![CDATA[1. All methods are implicitly public abstract. 2.All variables are implicitly final static constants. 3.Interface CAN NOT have static method. WHY : Java allows mult-interface implementation, what the child should inherit if two interfaces have the same static method? 4. casting a class to interface is always legal in Java during compile. eg. for A [...]]]></description>
			<content:encoded><![CDATA[<p>1. All methods are implicitly<strong> public abstract.</strong></p>
<p>2.All variables are implicitly <strong>final static</strong> constants.</p>
<p>3.Interface <strong>CAN NOT</strong> have static method.</p>
<p><em>WHY</em> :<span style="color: #888888;"> <span style="color: #0000ff;">Java allows mult-interface implementation, what the child should inherit if two interfaces have the same static method?</span></span></p>
<p>4. casting a class to interface is always legal in Java during compile.</p>
<p><em>eg.</em></p>
<p>for A class, you can cast it to an interface, this rule apply to instanceof as well.</p>
<p><span style="color: #0000ff;">eg1.Runnable r = (Runnable)new A(); </span></p>
<p><span style="color: #0000ff;">note: </span></p>
<p><span style="color: #0000ff;">but runtime if A has no relationship with Runnable, will throw Runtime Exception(ClassCastExcetption)</span></p>
<p><span style="color: #0000ff;">if A is a final class and has no relationship with Runnable, it will fail compile.<br />
</span></p>
<p><span style="color: #0000ff;">eg2.A a = (A)r; // this is legal as well.</span></p>
<p><span style="color: #0000ff;">eg3.$Left instaceof $Right, Left can be any objects,but no interface(fail the build), right can be interfaces</span></p>
<p><span style="color: #0000ff;">note:</span></p>
<p><span style="color: #0000ff;">again, compile will fail when $left is an ojbect of a final class, $right is an interface having no relationship with $left.<br />
</span></p>
<p><span style="color: #0000ff;"><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/04/24/java-interface-study-note/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Thread Study note</title>
		<link>http://kissnote.com/2010/04/24/java-thread-study-note/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/04/24/java-thread-study-note/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 22:01:17 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=207</guid>
		<description><![CDATA[1.A new Thread gets started means a new stack gets kicked off apart from the main stack 2. InterruptedException(checked exception) will be thrown when a thread is waiting, sleeping and pausing for long time. (sleep(), wait() and join()) note: yield() is not throwing this exception. 3.A thread can&#8217;t be started again once it&#8217;s started. Trying [...]]]></description>
			<content:encoded><![CDATA[<p>1.A new Thread gets started means a new stack gets kicked off apart from the main stack</p>
<p>2. InterruptedException(checked exception) will be thrown when a thread is waiting, sleeping and pausing for long time. (sleep(), wait() and join())</p>
<p>note:</p>
<p><span style="color: #0000ff;">yield() is not throwing this exception.</span></p>
<p>3.A thread can&#8217;t be started again once it&#8217;s started. Trying to start a thread more than once will throw IllegalThreadStateException(Runtime Exception)</p>
<p>4.wait(),notify(),notifyAll() are inherited from Object class. They have to be surrounded by the synchorized context. Otherwise it throws IllegalThreadMonitorException(Runtime Excpetion).</p>
<p><span style="color: #666699;">eg. sychronized(a) {</span></p>
<p><span style="color: #666699;">&#8230;.</span></p>
<p><span style="color: #666699;">a.wait()<br />
</span></p>
<p><span style="color: #666699;">&#8230;.<br />
</span></p>
<p><span style="color: #666699;">}</span></p>
<p>5. only thread can be started, not runnable.</p>
<p>6.Thread constructor can take  Runnable or <em><strong>String</strong></em>(name of the thread).</p>
<p><em><strong>Test Tips:</strong></em></p>
<p><em><strong>before you go any further, check the following!!!</strong></em></p>
<p><em><strong>Compile </strong></em></p>
<p>1. start() &#8211; check if it is against Runnable &#8211; compile error</p>
<p>2. wait(),join(),sleep() &#8211; InterruptedException is handled or not &#8211; compile error</p>
<p><em> </em></p>
<p>3.Thread.sleep() is ok, sleep() it self can be only called in the subclass of Thread. so class implements Runnable has to call Thread.sleep() not sleep() directly.</p>
<p><em><strong>Runtime<br />
</strong></em></p>
<p>1. wait(),notify(),notifyAll() needs to be in synchronized context &#8211;  runtime exception <em>IllegalMonitorStateException</em></p>
<p><em>2. </em>the same thread gets called start() twice &#8211; runtime exception &#8211; <em>IllegalThreadStateException</em></p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/04/24/java-thread-study-note/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Inner Class Study note</title>
		<link>http://kissnote.com/2010/04/24/java-inner-class/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/04/24/java-inner-class/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 13:13:09 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[scjp]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=200</guid>
		<description><![CDATA[Just quick sum-up what we should be careful during the SCJP exam when you see inner class questions. CAN 1. inner class can be defined in method, in class, as arugments as well. 2.Method local inner class can only have modifier abstract and final. CAN NOT 1. inner class CAN NOT have static methods. Neither [...]]]></description>
			<content:encoded><![CDATA[<p>Just quick sum-up what we should be careful during the SCJP exam when you see inner class questions.</p>
<h2>CAN</h2>
<p>1. inner class can be defined in method, in class, as arugments as well.</p>
<p>2.Method local inner class can only have modifier abstract and final.</p>
<h2>CAN NOT</h2>
<p>1. inner class CAN NOT have static methods. Neither static variable unless they are public static final constants</p>
<p>WHY</p>
<p><span style="color: #666699;">Because an inner class is implicitly associated with an instance of it&#8217;s  outer class, it cannot define any static methods itself.  Since a  static nested class cannot refer directly to instance variables or  methods defined in its enclosing class, it can use them only through an  object reference, it&#8217;s safe to declare static methods in a static nested  class.</span></p>
<p>2. method local inner class CAN NOT access method local variables unless they are Marked as final.</p>
<p>WHY</p>
<p><span style="color: #666699;">Simply because, the method local inner class is like an local variable. When the method completes, the object might still be passed by reference on the heap refered and used by some other code. The method local variable just can&#8217;t live as long as the method-local inner class object .</span></p>
<p>3.static inner class (this is not actually considered as regular inner class) CAN NOT have access to outer class&#8217;s instance members (non-static methods + instance variables)</p>
<p>4.static inner class can not extend a non-static inner class(Just burn this in mind)</p>
<p>WHY</p>
<p><span style="color: #666699;">Just like static method can&#8217;t directly access instace method, it has to be via object of the class. Static class can&#8217;t have the access to instance members.</span></p>
<p>4.inner class can be private+abstract, but CAN NOT be final+abstract.</p>
<p>WHY</p>
<p><span style="color: #666699;">it&#8217;s easy to tell , rite? hehe, just think about it.</span></p>
<h2><span style="color: #666699;"><br />
</span></h2>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/04/24/java-inner-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to mount remote windows drive to linux</title>
		<link>http://kissnote.com/2010/04/21/how-to-mount-remote-windows-drive-to-linux/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/04/21/how-to-mount-remote-windows-drive-to-linux/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 13:06:43 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[Tips Everyday]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mount]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=197</guid>
		<description><![CDATA[To remotely mount your windows driver to linux: eg. mount d drive, ﻿mount -t cifs -o username=${user},password=${password} //${IP}/d$ /mnt/windowsdriver t: file system tile (cifs or nfs, ntfs) o:options]]></description>
			<content:encoded><![CDATA[<p>To remotely mount your windows driver to linux:</p>
<p>eg. mount d drive,</p>
<p>﻿mount -t cifs -o username=${user},password=${password} //${IP}/d$ /mnt/windowsdriver</p>
<p>t: file system tile (cifs or nfs, ntfs)</p>
<p>o:options</p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/04/21/how-to-mount-remote-windows-drive-to-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCJP &#8211; scenarios you won&#8217;t get java compiled</title>
		<link>http://kissnote.com/2010/04/19/scjp-scenarios-you-wont-get-java-compiled/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2010/04/19/scjp-scenarios-you-wont-get-java-compiled/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 16:02:50 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[scjp]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=188</guid>
		<description><![CDATA[Arrays.length VS String.length() Most of the test tricks you by eg. args.length(), it will fail the compile. So don&#8217;t bother to figure out what results will be after execute. It won&#8217;t compile. Ambiguous This is a trick one, we will hit more ambiguous compile error in this article. One class implements/extends more than one parents. [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>
<h4>Arrays.length VS String.length()</h4>
</li>
</ul>
<p style="text-align: justify; padding-left: 30px;">Most of the test tricks you by eg. args.length(), it will fail the compile. So don&#8217;t bother to figure out what results will be after execute. It won&#8217;t compile.</p>
<ul>
<li>
<h4>Ambiguous</h4>
</li>
</ul>
<p style="padding-left: 30px;">This is a trick one, we will hit more ambiguous compile error in this article. One class implements/extends more than one parents. The parents have a same variable, the child has no idea which one gets inherited from what parent. Compile is confused and has no idea what to do. It gives you compile error(ambiguous).</p>
<p style="padding-left: 30px;">eg. class A{int a;}</p>
<p style="padding-left: 30px;">Inteface B{int a;}</p>
<p style="padding-left: 30px;">FAIL: class C extends A implements B{ compiler has no idea which a to inherit}</p>
<p style="padding-left: 30px;">eg.public void test(int&#8230; i) VS public void test(Integer&#8230; i)</p>
<p style="padding-left: 30px;">both in the same class, when we make a call like test(4), compile fails as ambiguous call is made</p>
<ul>
<li>
<h4>instanceof</h4>
</li>
</ul>
<p style="padding-left: 30px;">instanceof takes object on the left and interface/class on the right.So primitive will fail instanceof</p>
<p style="padding-left: 30px;">eg. FAIL: int i=1;</p>
<p style="padding-left: 30px;">i instanceof Integer is not legal, compile error.</p>
<ul>
<li>
<h4>binarySearch takes(List,key)</h4>
</li>
</ul>
<p style="padding-left: 30px;">eg. Collection c = new ArrayList();</p>
<p style="padding-left: 30px;">c.add(&#8220;shengjie&#8221;);</p>
<p style="padding-left: 30px;">&#8230;..</p>
<p style="padding-left: 30px;">Collections.binarySearch(c, &#8220;shengjie&#8221;); // compile error, c needs to have a explicit downcasting (List)c</p>
<ul>
<li>
<h4>Assignment</h4>
</li>
</ul>
<p style="padding-left: 30px;">List &lt;&#8211; ArrayList  OK &#8211; Polymorphism</p>
<p style="padding-left: 30px;">Integer &lt;&#8211; int OK &#8211; Auto-boxing</p>
<p style="padding-left: 30px;">Integer[] &lt;&#8211; int[] FAIL -  type is fixed when array initialised</p>
<ul>
<li>
<h4>passing param to method without explicit downcasting if downcasting is needed</h4>
</li>
<li>
<h4>Calendar.getInstance(Locale), SCJP test always tries to pass a date or smth else to Calendar.getInstance(Date) Compile Fail</h4>
</li>
<li>
<h4>When Overriding &#8211; It&#8217;s Public String toString(){} NOT <span style="text-decoration: line-through;">Public void toString(){}</span></h4>
</li>
<li>
<h4>Catch Exception Sequence</h4>
</li>
</ul>
<p style="padding-left: 30px;">sub-exception has to be caught before the super-exception, so the below will have compile error</p>
<p style="padding-left: 30px;">eg.try{</p>
<p style="padding-left: 30px;">}catch(RuntimeException){</p>
<p style="padding-left: 30px;">}catch(IllegalStateException){ // this can be thrown by calling matcher.group() when matcher.find() is not true</p>
<h4 style="padding-left: 30px;">}</h4>
<ul>
<li>
<h4>Private Inner Class can&#8217;t be called/accessed by other classes</h4>
</li>
</ul>
<p style="padding-left: 30px;">unlike the private fields can be accessed by getter/setter by other classes, inner class can&#8217;t be accessed by other classes. If the code snippet is trying to access the private inner class object, it fails the compile</p>
<ul>
<li>
<h4>Casting a class to anther class type which is not in the same hierarchy tree</h4>
</li>
</ul>
<ul>
<li>
<h4>static method tries to access Instance Member/Static class tries to access Instance Member</h4>
</li>
</ul>
<p style="padding-left: 30px;">Answer to WHY is pretty simply, because static goes with class other than instance. So&#8230;bear it in mind. Static class can be thought as static member of the enclosing class.</p>
<ul>
<li>
<h4>Final field is declared and no initialization</h4>
</li>
</ul>
<p style="padding-left: 30px;">public final int i; Compile Error</p>
<p style="padding-left: 30px;">public final int i=0; OK</p>
<ul>
<li>
<h4><span style="text-decoration: line-through;">Arrays.reverse()</span> doesn&#8217;t exist</h4>
</li>
</ul>
<p style="padding-left: 30px;">Arrays : sort() binarySearch()</p>
<p style="padding-left: 30px;">Collections: sort() binarySearch() reverse() reverseOrder()</p>
<p style="padding-left: 30px;">Don&#8217;t let the test play you like a fool!!!</p>
<ul>
<li>
<h4>wait(),notify(),notifyAll() throws InterruptedException which is not handled</h4>
</li>
</ul>
<p style="padding-left: 30px;">either catch it or throw it, doing nothing will fail the compile</p>
<ul>
<li>
<h4 style="padding-left: 30px;">Having unreachable code</h4>
</li>
</ul>
<p style="padding-left: 30px;">eg.</p>
<p style="padding-left: 30px;">&#8230;</p>
<p style="padding-left: 30px;">public void test() throws Exception{</p>
<p style="padding-left: 30px;">throw new RuntimeException();</p>
<p style="padding-left: 30px;">throw new anotherException(); // this is ok, i am not sure why, just burn into your mind</p>
<p style="padding-left: 30px;">int i = 0; // this never gets reached, so it fails the compile, tricky, yeah <img src='http://kissnote.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  LOL</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2010/04/19/scjp-scenarios-you-wont-get-java-compiled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>J2EE &#8211; JNDI</title>
		<link>http://kissnote.com/2009/07/27/j2ee-jndi/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://kissnote.com/2009/07/27/j2ee-jndi/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 23:53:45 +0000</pubDate>
		<dc:creator>shengjie</dc:creator>
				<category><![CDATA[J2EE]]></category>

		<guid isPermaLink="false">http://kissnote.com/?p=180</guid>
		<description><![CDATA[To understand JNDI, the only thing you need to learn is naming. Very simply example, DNS is a naming convention which is used to map the domain to IP. Such as www.test.com &#8211; 9.161.142.75. Another difficult thing to understand is LDAP (Lightweight Directory Access Protocol). most likely you will see it from the product where [...]]]></description>
			<content:encoded><![CDATA[<p>To understand <em><strong>JNDI</strong></em>, the only thing you need to learn is <strong>naming</strong>.</p>
<p>Very simply example,</p>
<p><em><strong>DNS </strong></em>is a naming convention which is used to map the domain to IP. Such as www.test.com &#8211; 9.161.142.75.</p>
<p>Another difficult thing to understand is <em><strong>LDAP </strong></em>(Lightweight Directory Access Protocol). most likely you will see it from the product where you have database storing all the users and you also have a LDAP server mapping all ther users as well (very popular usage).</p>
<p>Thus the LDAP name fn=Shengjie Min, p=SiChuan, c=CN names an LDAP entry fn=Shengjie Min, relative to the entry P=SiChuan,which in turn, is relative to C= CN.</p>
<p>So , back to the JNDI topic. JNDI allows us to look up any java object or LDAP directory based on the context. Hmm&#8230; not following..</p>
<p>Ok, one step by another,</p>
<h3>1. Bindings</h3>
<p>The association of a name with an object is called a <em>binding</em>. For example, a file name is <em>bound</em> to a file.</p>
<p>The DNS contains bindings that map machine names to IP addresses. An LDAP name is bound to an LDAP entry.</p>
<h3>2. Context</h3>
<p>A <em>context</em> is a set of name-to-object bindings</p>
<p>Examples are better than anything <img src='http://kissnote.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  That&#8217;s why i like them.</p>
<p>eg. you have a few database source(JDBC), let&#8217;s say they are a few databases. The context would be those databases entries. And to find one of the specific data source out of them, you will need to do a look up among those entries(context).</p>
<p>Given a code snippet to help out:</p>
<p><em><span style="color: #808080;">Context initCtx = new InitialContext();<span style="color: #ff00ff;"> // actually, to create a brand new initialContext, which can take hashmap as argument, you construct the hashmap to contain name-value pair. Just think of it as defining the scope of the look up</span><br />
</span></em></p>
<p><em><span style="color: #808080;">Context envCtx = (Context) initCtx.lookup(&#8220;java:comp/env&#8221;);</span></em></p>
<p><em><span style="color: #808080;">DataSource ds = (DataSource) envCtx.lookup(&#8220;jdbc/raDataSource&#8221;); </span><br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://kissnote.com/2009/07/27/j2ee-jndi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
