<?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>Chirag&#039;s Computer Blog</title>
	<atom:link href="http://techwithcj.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://techwithcj.wordpress.com</link>
	<description>A dose of my technical knowledge</description>
	<lastBuildDate>Tue, 06 Jul 2010 12:51:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='techwithcj.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Chirag&#039;s Computer Blog</title>
		<link>http://techwithcj.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://techwithcj.wordpress.com/osd.xml" title="Chirag&#039;s Computer Blog" />
	<atom:link rel='hub' href='http://techwithcj.wordpress.com/?pushpress=hub'/>
		<item>
		<title>toLowerCase() is Locale Based</title>
		<link>http://techwithcj.wordpress.com/2010/07/06/tolowercase-is-locale-based/</link>
		<comments>http://techwithcj.wordpress.com/2010/07/06/tolowercase-is-locale-based/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 12:51:21 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Development Basics]]></category>
		<category><![CDATA[Java Strings]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=84</guid>
		<description><![CDATA[I have found this very interesting and informative post for Java developers. Many Java developers may not know that toLowerCase(0 and toUpperCase() methods of java.lang.String class are Locale based. Have a look here at javadocs for these methods. toLowerCase() internally calls toLowerCase(Locale locale). Same is the case for toUpperCase(). Filed under: Java, Java Development Basics, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=84&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have found <a href="http://javapapers.com/core-java/javas-tolowercase-has-got-a-surprise-for-you/">this</a> very interesting and informative post for Java developers. Many Java developers may not know that toLowerCase(0 and toUpperCase() methods of java.lang.String class are Locale based. Have a look <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#toLowerCase%28%29">here</a> at javadocs for these methods.</p>
<p>toLowerCase() internally calls toLowerCase(Locale locale). Same is the case for toUpperCase().</p>
<br />Filed under: <a href='http://techwithcj.wordpress.com/category/java/'>Java</a>, <a href='http://techwithcj.wordpress.com/category/java/java-development-basics/'>Java Development Basics</a>, <a href='http://techwithcj.wordpress.com/category/java/java-strings-java/'>Java Strings</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=84&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2010/07/06/tolowercase-is-locale-based/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>Reading rss feed using java (JSP Taglib)</title>
		<link>http://techwithcj.wordpress.com/2010/05/13/reading-rss-feed-using-java-jsp-taglib/</link>
		<comments>http://techwithcj.wordpress.com/2010/05/13/reading-rss-feed-using-java-jsp-taglib/#comments</comments>
		<pubDate>Thu, 13 May 2010 09:53:24 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java RSS]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=74</guid>
		<description><![CDATA[We can read RSS (Real Simple Syndication) feeds and publish them on our web page using JSP(Java Server Pages) tag library. Sun provides a rss taglib that can be used in JSP. It is exremely simple to use. You just need to have basic knowledge of JSP and HTML. So, how to do that? First [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=74&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We can read RSS (Real Simple Syndication) feeds and publish them on our web page using JSP(Java Server Pages) tag library. Sun provides a rss taglib that can be used in JSP. It is exremely simple to use. You just need to have basic knowledge of JSP and  HTML.</p>
<p>So, how to do that? First you need to download the tag library file (rssutils.tld, rssutils.jar) from Sun&#8217;s website.<a href="http://java.sun.com/developer/technicalArticles/javaserverpages/rss_utilities/rss_utils_1.1.zip"> Here </a> is the url to download it. Put the files rssutils.tld and rssutils.jar in WEB-INF/lib directory of your web application.<br />
After that, choose a blog or website who publishes its rss feeds to users, and get the url of its rss feed. In below example, I have used the rss feed url of this blog. Please find the attached file <a href="http://techwithcj.files.wordpress.com/2010/05/rsstest-jsp.doc"> here </a>and save it with .jsp extension (rssTest.jsp)<br />
You can use  tag also to read content in a loop.<br />
For a small tutorial on rss taglib, go  <a href="http://java.sun.com/developer/technicalArticles/javaserverpages/rss_utilities/">here </a></p>
<p>To know what RSS is, go  <a href="http://en.wikipedia.org/wiki/RSS">here </a></p>
<br />Filed under: <a href='http://techwithcj.wordpress.com/category/java/'>Java</a>, <a href='http://techwithcj.wordpress.com/category/java/java-rss/'>Java RSS</a> Tagged: <a href='http://techwithcj.wordpress.com/tag/java-rss/'>Java RSS</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=74&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2010/05/13/reading-rss-feed-using-java-jsp-taglib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>enum as a class</title>
		<link>http://techwithcj.wordpress.com/2010/05/05/enum-as-a-class/</link>
		<comments>http://techwithcj.wordpress.com/2010/05/05/enum-as-a-class/#comments</comments>
		<pubDate>Wed, 05 May 2010 11:42:25 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Enums]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=72</guid>
		<description><![CDATA[Here I have compared enum with a class. In java, enums are like classes. What I have done here is, if we have to write a class that works like en enum, how can we do it. Though it is not of practicle use,what I have tried is to make the concept clear about enums.By [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=72&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here I have compared enum with a class. In java, enums are like classes.  What I have done here is, if we have to write a class that works like en enum, how can we do it. Though it is not of practicle use,what I have tried is to make the concept clear about enums.By comparing enum with a class, we can understand how enums work.</p>
<p>Here DayEnum is a enum and DayClass is class for that enum.</p>
<p>enum DayEnum {<br />
SUNDAY, MONDAY<br />
}<br />
class DayClass {</p>
<p>String value;</p>
<p>public DayClass (String str)</p>
<p>{</p>
<p>value=str;</p>
<p>}</p>
<p>static DayClass SUNDAY, MONDAY;</p>
<p>static</p>
<p>{</p>
<p>SUNDAY = new DayClass(&#8220;SUNDAY&#8221;);</p>
<p>MONDAY = new DayClass(&#8220;MONDAY&#8221;);</p>
<p>}</p>
<p>}</p>
<p>public class Test</p>
<p>{</p>
<p>public static void main(String args[])</p>
<p>{</p>
<p>DayClass dayClass = DayClass.SUNDAY;</p>
<p>DayEnum dayEnum = DayEnum.SUNDAY;</p>
<p>System.out.print(&#8220;dayClass &#8220;+dayClass.value+&#8221; \n dayEnum &#8220;+dayEnum);</p>
<p>}</p>
<p>}</p>
<p>Here SUNDAY, MONDAY are similar to static objects of Day if Day were a class.</p>
<p>We use enum as:<br />
DayEnum day = DayEnum.SUNDAY;</p>
<p>enums are like constants. To simulate that, I have used <em>value</em> in DayClass. So every object of DayClass has an integer value associated with it.</p>
<br />Filed under: <a href='http://techwithcj.wordpress.com/category/java/enums/'>Enums</a>, <a href='http://techwithcj.wordpress.com/category/java/'>Java</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=72&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2010/05/05/enum-as-a-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Good Practices</title>
		<link>http://techwithcj.wordpress.com/2010/02/12/java-good-practices/</link>
		<comments>http://techwithcj.wordpress.com/2010/02/12/java-good-practices/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 07:38:07 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Development Basics]]></category>
		<category><![CDATA[Java Exceptions]]></category>
		<category><![CDATA[Java Strings]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=70</guid>
		<description><![CDATA[Here is an article on java good practices.Have a look! Filed under: Java, Java Development Basics, Java Exceptions, Java Strings<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=70&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://viralpatel.net/blogs/2010/02/most-useful-java-best-practice-quotes-java-developers.html">Here</a> is an article on java good practices.Have a look!</p>
<br />Filed under: <a href='http://techwithcj.wordpress.com/category/java/'>Java</a>, <a href='http://techwithcj.wordpress.com/category/java/java-development-basics/'>Java Development Basics</a>, <a href='http://techwithcj.wordpress.com/category/java/java-exceptions/'>Java Exceptions</a>, <a href='http://techwithcj.wordpress.com/category/java/java-strings-java/'>Java Strings</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=70&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2010/02/12/java-good-practices/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>Private Fields of Reference Type</title>
		<link>http://techwithcj.wordpress.com/2010/02/12/private-fields-of-reference-type/</link>
		<comments>http://techwithcj.wordpress.com/2010/02/12/private-fields-of-reference-type/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 06:20:12 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Development Basics]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=68</guid>
		<description><![CDATA[Hi, today I stumbled upon a strange problem while wriring some java code. There is a class with a private field of reference type, say an ArrayList. Now,what is the use of private fields? They are used so that they can not be modified from outside the class like public fields. General practice is to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=68&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi, today I stumbled upon a strange problem while wriring some java code.<br />
There is a class with a private field of reference type, say an ArrayList. Now,what is the use of private fields? They are used so that they can not be modified from outside the class like public fields. General practice is to provide getter methods in the class to return the values of private fields.It goes fine with the primitive type variables and Strings(because Strings are immutable). But when the field is of reference type, we can still change its value.Have a look at the code:</p>
<p><code><br />
import java.util.*;</p>
<p>class Aclass<br />
{</p>
<p>private ArrayList list;<br />
private String s= "My string";</p>
<p>public Aclass()<br />
{<br />
list= new ArrayList();<br />
list.add("Hello");<br />
}</p>
<p>public ArrayList getList()<br />
{<br />
return list;<br />
}</p>
<p>public String getString()<br />
{<br />
return s;<br />
}</p>
<p>}</p>
<p>public class TestPrivate<br />
{</p>
<p>public static void main(String args[])<br />
{<br />
Aclass ob= new a();<br />
ArrayList alist= ob.getList();<br />
System.out.println(l2);<br />
alist.add("Hi");<br />
ArrayList anotherList= ob.getList();<br />
System.out.println(anotherList);</p>
<p>String s2= ob.getString();<br />
System.out.println(s2);<br />
s2="changed";<br />
String s3= ob.getString();<br />
System.out.println(s3);<br />
}<br />
}<br />
</code></p>
<p>When you run this code,the output is:<br />
<code><br />
[Hello]<br />
[Hello, Hi]<br />
My string<br />
My string<br />
</code><br />
You can see that content of list has been changed, but for string, they are not changed.So you can change the list object even if it is private.It is because the getList() method returns the reference to the same list object, so we can modify the list even if it is private.Now if you think that it is some loophole or bug of java,the you are wrong.It is just a simple basic concept of reference type variables.</p>
<p>Now, what should you do to avoid this thing. You have to modify the getList() method so that it returns the clone of list, not the actual list object.Here is the solution:<br />
<code><br />
public ArrayList getList()<br />
{<br />
return (ArrayList) list.clone();<br />
}<br />
</code><br />
clone() will return the clone of object, not the actual list. Return type  of clone() is Object, so we have to typecast it to ArrayList. Any modification done from the reference returned by this method will not change the actual one.DFor more information on clone() method,<br />
<a href="http://techwithcj.wordpress.com/2010/01/22/cloning-of-objects-using-clone-in-java/">go here.</a></p>
<br />Filed under: <a href='http://techwithcj.wordpress.com/category/java/'>Java</a>, <a href='http://techwithcj.wordpress.com/category/java/java-development-basics/'>Java Development Basics</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=68&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2010/02/12/private-fields-of-reference-type/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>Problem With clone() if Object Has a Reference Type Attribute</title>
		<link>http://techwithcj.wordpress.com/2010/01/22/problem-with-clone-if-object-has-a-reference-type-attribute/</link>
		<comments>http://techwithcj.wordpress.com/2010/01/22/problem-with-clone-if-object-has-a-reference-type-attribute/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 13:01:30 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java Development Basics]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=63</guid>
		<description><![CDATA[You might have used the clone() method of Object class to get a clone of an object.But have you ever faced a problem if your object has reference type attributes? Well, I have, and thats what I am going to discuss in this post. A class can have two types of class level variables,primitive type [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=63&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You might have used the clone() method of Object class to <a href="http://techwithcj.wordpress.com/2010/01/22/cloning-of-objects-using-clone-in-java/">get a clone</a> of an object.But have you ever faced a problem if your object has reference type attributes? Well, I have, and thats what I am going to discuss in this post.<br />
A class can have two types of class level variables,primitive type (as int,float) and reference type(as List).Here is an example:</p>
<p><code>class AClass<br />
{<br />
int i;        //primitive type<br />
List alist;  //reference type<br />
}</code><br />
For more on types,<a href="http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html"> click here</a></p>
<p>Well, lets return on the original topic.When we make a clone of an object, the primitive type variables are copied in the new clone object, but for the reference type variables,only the reference is copied, not the original instance.For example, if we create the clone of above class&#8217;s object,there will be only one List object, and both object will have a reference to this.Here is what I tried:</p>
<p><code>public class ClassToClone  {<br />
    ArrayList list;<br />
   public ClassToClone(ArrayList list)<br />
    {<br />
        this.list=list;<br />
    }</p>
<p>    protected Object clone()<br />
    {<br />
        try{<br />
               return super.clone();<br />
        }<br />
        catch(CloneNotSupportedException e)<br />
        {<br />
            return null;<br />
        }<br />
    }<br />
}</code></p>
<p>To test it:<br />
<code>public class TestClone  {<br />
    public static void main(String args[])<br />
    {<br />
        ClassToClone c1,c2;<br />
        ArrayList arraylist= new ArrayList();<br />
        arraylist.add("Hello");<br />
        c1= new ClassToClone(arraylist);<br />
        c2 = (ClassToClone)c1.clone();<br />
        c1.list.add("Hi"); //change contents of the list of c1<br />
        System.out.print(c1.list.toString());<br />
        System.out.print(c2.list.toString()); // prints the list of both objects<br />
    }<br />
}</code></p>
<p>When you run this program, you will see that on changing the list of c1, list of c2 is also changed and they both have the same content.<br />
To avoid this problem, you have to explicitly clone the reference type variables. In ClassToClone, repalce clone() method by this:</p>
<p><code>protected Object clone()<br />
    {<br />
        try{<br />
            ClassToClone aobj = (ClassToClone)super.clone();<br />
                            aobj.s = (ArrayList)list.clone();<br />
                                             //explicit call to clone() for arraylist<br />
                            return aobj;</p>
<p>        }<br />
        catch(CloneNotSupportedException e)<br />
        {<br />
            return null;<br />
        }<br />
    }</code></p>
<p>Here we have explicitly cloned the arraylist.Now a new list will be created for clone object.Now changes done in c1.list do not reflect in c2.list.You can try this by yourself.But remember,<strong>clone() can be called only if the class implements Cloneable interface</strong>, otherwise we get <em>CloneNotSupportedException</em>.Here class ArrayList implements this interface.<br />
<a href="http://java.sun.com/developer/JDCTechTips/2001/tt0306.html">Here</a> and <a href="http://en.wikipedia.org/wiki/Clone_%28Java_method%29">here</a> is a great article to read on object cloning.</p>
<br />Posted in Java Development Basics  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=63&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2010/01/22/problem-with-clone-if-object-has-a-reference-type-attribute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>Cloning of Objects Using clone() in Java</title>
		<link>http://techwithcj.wordpress.com/2010/01/22/cloning-of-objects-using-clone-in-java/</link>
		<comments>http://techwithcj.wordpress.com/2010/01/22/cloning-of-objects-using-clone-in-java/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 12:06:46 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java Development Basics]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=60</guid>
		<description><![CDATA[java.lang.Object class provides a native method clone(). Calling this method on your object will return a clone of that object.”Clone” here means what in normal world the word “clone” means. A clone object is another object having same attribute values as the original object.Here is the how to do cloning of objects: public class ClassToClone [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=60&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>java.lang.Object</strong> class provides a native method clone(). Calling this method on your object will return a clone of that object.”Clone” here means what in normal world the word “clone” means. A clone object is another object having same attribute values as the original object.Here is the how to do cloning of objects:</p>
<p><code>public class ClassToClone implements Cloneable {<br />
    int i;<br />
    public ClassToClone(int i)<br />
    {<br />
        this.i=i;<br />
    }<br />
    protected Object clone()<br />
    {<br />
        try<br />
           {<br />
               return super.clone();<br />
           }<br />
        catch(CloneNotSupportedException e)<br />
        {<br />
            return null;<br />
        }<br />
    } //end of clone method<br />
}//end of class</code></p>
<p><strong>clone()</strong> in Object has <em>protected</em> access. So we have to override the clone() and call super.clone() from it(As Object is duperclass of every class).To ensure that our class is cloneable,i.e. it supports cloning functionality, it has to implement java.lang.Cloneable interface.Cloneable inteface does not have any method inside it.It is just a markup interface, used to tell other classes that our class supports cloning.<br />
Now a small note on how it works.When clone() of Object class is called on an object, a new object is created of that class and all the attribute&#8217;s values are copied from original to new object.<br />
Now because these two objects are different,calling (obj1==obj2) will give false.<br />
<a href="http://java.sun.com/developer/JDCTechTips/2001/tt0306.html">Here</a> and <a href="http://en.wikipedia.org/wiki/Clone_%28Java_method%29">here</a> is a great article about object cloning.</p>
<br />Posted in Java Development Basics  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=60&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2010/01/22/cloning-of-objects-using-clone-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>&#8220;Code Too Large&#8221; problem in java</title>
		<link>http://techwithcj.wordpress.com/2010/01/19/code-too-large-problem-in-java/</link>
		<comments>http://techwithcj.wordpress.com/2010/01/19/code-too-large-problem-in-java/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 06:17:23 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Development Basics]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=55</guid>
		<description><![CDATA[Today while browsing through the internet, I found a very strange thing. I am sure it will be a very new and unknown fact for most of the java programmers, even the well experienced ones. The reason is because while working on a project, problem of this type does not occur very often. Now what [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=55&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today while browsing through the internet, I found a very strange thing. I am sure it will be a very new and  unknown fact for most of the java programmers, even the well  experienced ones. The reason is because while working on a project, problem of this type does not occur very often. Now what kind of problem am I talking about? Well, most of you must have had a slight idea by looking at the title of the post. It says something when we have written a very large code and the compiler produces the error. Here is the snapshot of what I tried myself after reading this thing on internet:</p>
<p><code>C:\Documents and Settings\chirag.jain\Desktop&gt;javac  LargeCode.java<br />
LargeCode.java:3: code too large<br />
void largeMethod()<br />
1 error<br />
</code><br />
<em><strong>So does the java compiler inforces any limitation on the size of the code?</strong> </em>The answer is yes, and that boundary is <strong>65536 Bytes.</strong> <strong>This limitation is not on the size of whole file, but on a single method.</strong><br />
Now lets us delve a bit in the details. When we compile a java source file(.java file), compiler produces the byte code in .class file. <strong>When the size of the byte code of a single method crosses 65536 bytes, the compiler is not able to compile that method, and gives “code too large” error for that particular method.</strong><br />
Now here is one thing to notice. <strong>The overall size of your class file can grow more than 65536 bytes, but the byte code for a single method should not be more than this</strong>. Notice that here I am getting this error for a method named largeMethod(), not for the whole file.<br />
Now for the folks who want to try this by themselves. First  thing is how would you generate such a large amount of code. Although there are some code generation tools like Groovy, but these are for large projects. To try it by yourselves, you can do what I did. Here is my code:</p>
<p>import java.io.*;</p>
<p>class WriteFile<br />
{<br />
public static void main(String args[])<br />
{<br />
BufferedWriter bw=null;<br />
try{<br />
File f= new File(&#8220;LargeCode.java&#8221;);<br />
FileWriter fr= new FileWriter(f);<br />
 bw= new BufferedWriter(fr);<br />
String s= &#8220;System.out.println(\&#8221;hello\&#8221;);&#8221;;<br />
for(int i=0;i&lt;10000;i++)<br />
{<br />
    bw.write(s);<br />
}</p>
<p>bw.close();</p>
<p>}<br />
catch(Exception e) { }<br />
}<br />
}</p>
<p>Here I have generated a new file using java IO API. It writes the statement<br />
System.out.println(&#8220;hello&#8221;);<br />
10,000 times in a separate file.  Now you can add other things (class name, method name) to compile the program. If you write the whole code in a single method, you will get the error. </p>
<br />Posted in Java, Java Development Basics  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=55&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2010/01/19/code-too-large-problem-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>Ways of Creating Strings in java: String Literal Pool</title>
		<link>http://techwithcj.wordpress.com/2009/12/24/ways-of-creating-strings-in-java-string-literal-pool/</link>
		<comments>http://techwithcj.wordpress.com/2009/12/24/ways-of-creating-strings-in-java-string-literal-pool/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 13:18:56 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Strings]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=47</guid>
		<description><![CDATA[String Literal Pool: String str=”hello”; willl go to String literal pool managed by String class and will reuse the “hello” string if it is already present, otherwise creates new “hello” in pool. String str=new String(“hello”) every time creates new object in heap. Garbage collector never looks in String literal pool. String literal pool is also [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=47&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<ul>
<strong>String Literal Pool:</strong></ul>
<p><code>String str=”hello”;</code><br />
willl go to String literal pool managed by String class and will reuse the “hello” string if it is already present, otherwise creates new “hello” in pool.<br />
<code>String str=new String(“hello”)</code><br />
 every time creates new object in heap.</p>
<p>Garbage collector never looks in String literal pool. String literal pool is also a part of heap memory.</p>
<p>So:</p>
<p><code>    String s1 = “hello”;<br />
    String s2 = “hello”;<br />
    System.out.println(s1==s2);</code> // true.</p>
<p>Object s2 is the same object with s1. But if you create using new operator:</p>
<p>   <code> String s1 = “hello”;<br />
    String s2 = new String(“hello”);<br />
    System.out.println(s1==s2);</code>//false<br />
<a href="http://www.xyzws.com/Javafaq/what-is-string-literal-pool/3">Here</a> is a great article about Strings.</p>
<br />Posted in Java, Java Strings  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=47&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2009/12/24/ways-of-creating-strings-in-java-string-literal-pool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Scanner class to get input from user in java</title>
		<link>http://techwithcj.wordpress.com/2009/12/24/using-scanner-class-to-get-input-from-user-in-java/</link>
		<comments>http://techwithcj.wordpress.com/2009/12/24/using-scanner-class-to-get-input-from-user-in-java/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 13:02:13 +0000</pubDate>
		<dc:creator>Chirag Jain</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java IO]]></category>

		<guid isPermaLink="false">http://techwithcj.wordpress.com/?p=45</guid>
		<description><![CDATA[java.util.Scanner class provides a way to get input from user: Scanner scanner = new Scanner(System.in); If input is String: String string= scanner.nextLine();//to read input as a whole line or String string= scanner.next(); // to read single word To read integers: int i= scanner.nextInt(); Here is an article helpful on Scanner. Posted in Java, Java IO<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=45&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>java.util.Scanner class provides a way to get input from user:</p>
<p>Scanner scanner = new Scanner(System.in);</p>
<p>If input is String:</p>
<p><code>String string= scanner.nextLine();</code>//to read input as a whole line</p>
<p>or</p>
<p><code>String string= scanner.next();</code> // to read single word</p>
<p>To read integers:</p>
<p><code>int i= scanner.nextInt();</code></p>
<p><a href="http://www.java-made-easy.com/java-scanner-help.html">Here</a> is an article helpful on Scanner.</p>
<br />Posted in Java, Java IO  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techwithcj.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techwithcj.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techwithcj.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techwithcj.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techwithcj.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techwithcj.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techwithcj.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techwithcj.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techwithcj.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techwithcj.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techwithcj.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techwithcj.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techwithcj.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techwithcj.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techwithcj.wordpress.com&amp;blog=10543029&amp;post=45&amp;subd=techwithcj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techwithcj.wordpress.com/2009/12/24/using-scanner-class-to-get-input-from-user-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fd31ac18260261bfecc180a5f24bd8f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chirag Jain</media:title>
		</media:content>
	</item>
	</channel>
</rss>
