<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4602628487645977758</id><updated>2024-11-01T03:34:34.041-07:00</updated><category term="JAVA TIPS"/><category term="Java technical tips"/><category term="JAVA"/><category term="Java Interview Questions"/><category term="Collection API"/><category term="Deque"/><category term="File in Java"/><category term="Java 6.0"/><category term="Regular Expression"/><category term="ArrayDeque"/><category term="Collection Interview Question"/><category term="Colletion Interview Question"/><category term="Comment line in Java"/><category term="Connect to shared folder in Java"/><category term="Control character in java"/><category term="Deque and ArrayDeque example"/><category term="Feature Of JDK 7"/><category term="Garbage Collector"/><category term="JDK 7"/><category term="Java Colletion"/><category term="Java FINAL keyword"/><category term="Java Garbage Collector"/><category term="New Feathers of Collection APIs"/><category term="New in JDK 7"/><category term="Replace word in a String"/><category term="Stop a thread"/><category term="Thread"/><category term="Thread in Java"/><category term="java Objects"/><category term="limited objects"/><category term="restricted class"/><title type='text'>The Age Of Java</title><subtitle type='html'>&quot;Before software can be reusable it first has to be usable&quot;- Ralph Johnson</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-1736783963938836432</id><published>2014-10-10T09:19:00.001-07:00</published><updated>2014-10-10T22:26:10.640-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Interview Questions"/><category scheme="http://www.blogger.com/atom/ns#" term="Stop a thread"/><category scheme="http://www.blogger.com/atom/ns#" term="Thread"/><category scheme="http://www.blogger.com/atom/ns#" term="Thread in Java"/><title type='text'>How to Stop A Thread in Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;Here is one of the most asked question interviewer asks very often.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;How can we stop a thread..??&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;As we know &lt;b&gt;Thread&lt;/b&gt; is one of important Class in Java and multi-threading is most widely used feature, but there is no clear way to stop Thread in Java. Earlier there was a stop method exists in Thread Class but Java deprecated that method citing some safety reason. By default a Thread stops when execution of run() method finish either normally or due to any Exception. In this article we will How to Stop Thread in Java by using a boolean State variable or flag. Using flag to stop Thread is very popular way&amp;nbsp; of stopping thread and its also safe, because it doesn&#39;t do anything special rather than helping run() method to finish it self.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;Another important point is that you can not restart a Thread which run() method has finished already , you will get an IllegalStateExceptio, following is a Sample Code for stopping a Thread in Java:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp; private class Runner extends Thread{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; boolean bExit = false;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void exit(boolean bExit){&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.bExit = bExit;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void run(){&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!bExit){&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Thread is running&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.sleep(500);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (InterruptedException ex) {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logger.getLogger(ThreadTester.class.getName()).log(Level.SEVERE, null, ex);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; border: medium none; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small; padding: 0in;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Calibri, sans-serif; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;
&lt;b&gt;Should we make bExit Volatile ?&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: 9pt;&quot;&gt;Since every Thread has its own local memory in Java its good practice to make bExit volatile because we may alter value of bExit from any thread and making it volatile guarantees that Runner will also see any update done before making bExit.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: 9pt;&quot;&gt;That’s all on how to stop thread in Java , let me know if you find any other way of stopping threads in Java without using deprecated stop() method.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/1736783963938836432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2014/10/how-to-stop-thread-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/1736783963938836432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/1736783963938836432'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2014/10/how-to-stop-thread-in-java.html' title='How to Stop A Thread in Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-8897293560480522459</id><published>2012-04-27T00:05:00.000-07:00</published><updated>2012-04-27T00:05:05.880-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Interview Questions"/><category scheme="http://www.blogger.com/atom/ns#" term="java Objects"/><category scheme="http://www.blogger.com/atom/ns#" term="limited objects"/><category scheme="http://www.blogger.com/atom/ns#" term="restricted class"/><title type='text'>How Can We restrict someone to create a limited objects of a class</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;postbody&quot;&gt;Here is example how we can restrict someone to create a limited objects of a class :-&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;postbody&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;class Example{&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static int count;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static int MAX_COUNT = 5;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Example(){&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static Example getObject(){&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(count &amp;lt; MAX_COUNT){&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count ++;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new Example&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;();&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else{&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;You exceded the limit&quot;);&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //TO DO&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/8897293560480522459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2012/04/how-can-we-restrict-someone-to-create.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/8897293560480522459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/8897293560480522459'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2012/04/how-can-we-restrict-someone-to-create.html' title='How Can We restrict someone to create a limited objects of a class'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-3207360117806768184</id><published>2012-02-08T08:52:00.000-08:00</published><updated>2012-02-08T09:00:22.386-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Collection API"/><category scheme="http://www.blogger.com/atom/ns#" term="Collection Interview Question"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Interview Questions"/><title type='text'>Top Java Collection Interview Questions</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;1) What is the Collections API?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The Collections API is a set of classes and interfaces that support operations on collections of objects.&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;2) What is the List interface?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The List interface provides support for ordered collections of objects. &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;3) What is the Vector class?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The Vector class provides the capability to implement a growable array of objects. &amp;nbsp;&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;4) What is an Iterator interface?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The Iterator interface is used to step through the elements of a Collection .&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;5) Which java.util classes and interfaces support event handling?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The EventObject class and the EventListener interface support event processing.&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;6) What is the GregorianCalendar class?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The GregorianCalendar provides support for traditional Western calendars &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;7) What is the Locale class?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region .&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;8) What is the SimpleTimeZone class?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The SimpleTimeZone class provides support for a Gregorian calendar .&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;9) What is the Map interface?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;10) What is the highest-level event class of the event-delegation model?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;11) What is the Collection interface?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The Collection interface provides support for the implementation of a mathematical bag, an unordered collection of objects that may contain duplicates.&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;12) What is the Set interface?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements. &lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;13) What is the typical use of Hashtable?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: Whenever a program wants to store a key value pair, one can use Hashtable.&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;14) What is the difference between the size and capacity of a Vector?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time.&lt;/span&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,sans-serif;&quot;&gt;15) Can a vector contain heterogenous objects?&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A: Yes a Vector can contain heterogenous objects. Because a Vector stores everything in terms of Object.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/3207360117806768184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2012/02/top-java-collection-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/3207360117806768184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/3207360117806768184'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2012/02/top-java-collection-interview-questions.html' title='Top Java Collection Interview Questions'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-8712360015830583524</id><published>2012-02-08T08:36:00.000-08:00</published><updated>2012-02-08T08:36:03.499-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Collection API"/><category scheme="http://www.blogger.com/atom/ns#" term="Colletion Interview Question"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Colletion"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Interview Questions"/><title type='text'>Important Java Collection Interview Questions &amp; Answers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;What is difference between Set and List in Java?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Most of Java programmer knows that Set doesn&#39;t  allowed duplicate while List does and List maintains insertion order  while Set doesn&#39;t. What is key here is to show interviewer that you can  decide which collection is more suited based on requirements.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Difference between HashMap and Hashtable?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;HashMap  is not synchronized while hashtalbe is  not or hashmap is faster than hashtable etc. What could go wrong is that  if he placed another followup question like how hashMap works in Java  or can you replace Hashtable with ConcurrenthashMap etc. See HashTable  vs HashMap in Java for detailed answer of this interview question.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;What is difference between Synchronized Collection and ConcurrentCollection?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Java5  has added several new ConcurrentCollection classes e.g.  ConcurrentHashMap, CopyOnWriteArrayList, BlockingQueue etc, which has  made Interview questions on Java Collection even trickier. Java Also  provided way to get Synchronized copy of collection e.g. ArrayList,  HashMap by using Collections.synchronizedMap() Utility function.One  Significant difference is that ConccurentCollections has better  performance than synchronized Collection because they lock only a  portion of Map to achieve concurrency and Synchronization.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&amp;nbsp; &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;What is difference between fail-fast and fail-safe Iterators?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Fail-fast Iterators throws ConcurrentModificationException when  one Thread  is iterating over collection object and other thread structurally  modify Collection either by adding, removing or modifying objects on  underlying collection. They are called fail-fast because they try to  immediately throw Exception when they encounter failure. On the other  hand fail-safe Iterators works on copy of collection instead of original collection&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;a href=&quot;http://www.blogger.com/goog_735950745&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;What is difference between Iterator and Enumeration?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Iterator duplicate functionality of Enumeration with one addition  of remove() method and both provide navigation functionally on objects  of Collection.Another difference is that Iterator is more safe than  Enumeration and doesn&#39;t allow another thread to modify collection object  during iteration except remove() method and throws  ConcurrentModificaitonException. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;When do you use ConcurrentHashMap in Java?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;ConcurrentHashMap is  better suited for situation where you have multiple readers and one Writer or fewer writers since Map gets locked only during write operation. If you have equaled number of reader and writer than ConcurrentHashMap will perform in line of hashtable or synchronized hashMap.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;How do you Sort objects on collection?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Sorting is implemented using Comparable and  Comparator in Java and when you call Collections.sort() it gets sorted  based on natural order specified in CompareTo method while  Collections.sort(Comparator) will sort objects based on compare() method  of Comparator.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana,sans-serif; font-size: small;&quot;&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/8712360015830583524/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2012/02/important-java-collection-interview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/8712360015830583524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/8712360015830583524'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2012/02/important-java-collection-interview.html' title='Important Java Collection Interview Questions &amp; Answers'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-5599735648133355762</id><published>2012-02-08T08:13:00.000-08:00</published><updated>2012-02-08T08:17:40.146-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Garbage Collector"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Garbage Collector"/><title type='text'>Types of Garbage Collector in Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Java Runtime(J2SE 5) provides various &lt;b&gt;types of Garbage collection in Java&lt;/b&gt; which we can choose based upon our application&#39;s performance requirement. J2SE 5 adds three additional &lt;b&gt;garbage collectors&lt;/b&gt; except &lt;b&gt;serial garbage collector&lt;/b&gt;. Each is &lt;b&gt;generational garbage collector&lt;/b&gt; which has been implemented to increase throughput of the application or to reduce &lt;b&gt;garbage collection pause times&lt;/b&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;1) &lt;u&gt;&lt;b&gt;Throughput Garbage Collector&lt;/b&gt;:&lt;/u&gt; This garbage collector in Java uses a parallel version of the young generation collector. It is used if the -XX:+UseParallelGC option is passed to the JVM via command line options . The tenured generation collector is same as the serial collector.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;2) &lt;u&gt;&lt;b&gt;Concurrent low pause Collector&lt;/b&gt;:&lt;/u&gt; This Collector is used if the -Xingc or &lt;b&gt;-XX:+UseConcMarkSweepGC&lt;/b&gt; is passed on the command line. This is also referred as &lt;b&gt;Concurrent Mark Sweep Garbage collector&lt;/b&gt;.  The concurrent collector is used to collect the tenured generation and  does most of the collection concurrently with the execution of the  application. The application is paused for short periods during the  collection. A parallel version of the young generation copying collector  is sued with the concurrent collector. Concurrent Mark Sweep Garbage  collector is most widely used garbage collector in java and it uses  algorithm to first mark object which needs to collected when garbage  collection triggers.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;3) &lt;u&gt;&lt;b&gt;The Incremental (Sometimes called train) low pause collector&lt;/b&gt;:&lt;/u&gt; This collector is used only if -&lt;b&gt;XX:+UseTrainGC&lt;/b&gt;  is passed on the command line. This garbage collector has not changed  since the java 1.4.2 and is currently not under active development. It  will not be supported in future releases so avoid using this and please  see 1.4.2 GC Tuning document for information on this collector.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;Important point to not is that &lt;b&gt;-XX:+UseParallelGC&lt;/b&gt; should not be used with &lt;b&gt;-XX:+UseConcMarkSweepGC&lt;/b&gt;.  The argument passing in the J2SE platform starting with version 1.4.2  should only allow legal combination of command line options for garbage  collector but earlier releases may not find or detect all illegal  combination and the results for illegal combination are unpredictable.  It’s not recommended to use this garbage collector in java.&lt;/span&gt;&lt;/span&gt;       &lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/5599735648133355762/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2012/02/types-of-garbage-collector-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/5599735648133355762'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/5599735648133355762'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2012/02/types-of-garbage-collector-in-java.html' title='Types of Garbage Collector in Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-7100526573432230660</id><published>2011-11-21T10:55:00.001-08:00</published><updated>2011-11-21T11:13:35.452-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ArrayDeque"/><category scheme="http://www.blogger.com/atom/ns#" term="Deque"/><category scheme="http://www.blogger.com/atom/ns#" term="Deque and ArrayDeque example"/><category scheme="http://www.blogger.com/atom/ns#" term="Java 6.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Java technical tips"/><title type='text'>Deque and ArrayDeque</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 13px;&quot;&gt;Deque is the abbreviation of “Double Ended Queue”. A Collection that allows us to add (or) remove elements at both ends. Deque supports total size of collection for both fixed and unspecified size limits.&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
Deque&amp;nbsp;implementation&amp;nbsp;can be used as Stack(Last in first out ) or Queue(First in First Out). For each insertion, retrieval and removal of elements from deque there exists methods in 2 flavours. One will throw exception if it fails in an operation&amp;nbsp;and another one returns status or special value for each&amp;nbsp;operation.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; height=&quot;200&quot; style=&quot;font-family: Verdana; width: 529px;&quot; summary=&quot;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;b&gt;Operation&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;b&gt;Special value method&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;b&gt;Exception throwing method&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;Insertion at head&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;offerFirst(e)&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;addFirst(e)&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;Removal at head&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;pollFirst()&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;removeFirst()&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: x-small;&quot;&gt;Retrieval at&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;Head&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;peekFirst()&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;getFirst()&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;Insertion at Tail&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;offerLast(e)&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;addLast(e)&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;Removal at Tail&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;pollLast()&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;removeLast()&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: x-small;&quot;&gt;Retrieval at&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;Tail&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;peekLast()&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;getLast()&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
Implementation&amp;nbsp;of Deque doesn’t require preventing the insertion of null, but when we are using special value method null is return to indicate that collection is empty. So it is recommendable not to allow insertion of null.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
ArrayDeque is a class that implements Deque. It has no capacity restrictions. It will perform faster than stack when used as stack and faster than linked list when used as queue. ArrayDeque is not thread Safe. The following example explains how to write program using ArrayDeque.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: -webkit-auto;&quot;&gt;
&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;import java.util.ArrayDeque;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;import java.util.Iterator;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;public class DequeExample&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String as[])&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayDeque adObj = new ArrayDeque();&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;//Insertion by using various methods&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;adObj.add(&quot;Oracle&quot;);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;adObj.addFirst(&quot;DB2&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;adObj.offerFirst(&quot;MySQL&quot;); &amp;nbsp; //returns boolean - true R false&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;adObj.offerLast(&quot;Postgres&quot;); &amp;nbsp; //returns boolean - true R false&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;//Retrievals&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Retrieving First Element :&quot; + adObj.peekFirst());&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Retrieving Last Element &amp;nbsp;:&quot;+ adObj.peekLast());&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;//Removals&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Removing First &amp;nbsp;Element &amp;nbsp;:&quot;+ adObj.pollFirst());&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Removing Last &amp;nbsp;Element &amp;nbsp; :&quot;+ adObj.pollLast());&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;//Reverse traversal&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Remaining Elements :&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator it = adObj.descendingIterator();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;while(it.hasNext())&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.out.println(it.next());&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;Retrieving First Element :MySQL&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;Retrieving Last Element &amp;nbsp;:Postgres&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;Removing First &amp;nbsp;Element &amp;nbsp;:MySQL&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;Removing Last &amp;nbsp;Element &amp;nbsp; :Postgres&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;Remaining Elements :&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;Oracle&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana;&quot;&gt;DB2&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: x-small;&quot;&gt;For more please visit-&amp;nbsp;&lt;a href=&quot;http://download.oracle.com/javase/6/docs/api/java/util/ArrayDeque.html&quot; style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium;&quot;&gt;http://download.oracle.com/javase/6/docs/api/java/util/ArrayDeque.html&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/7100526573432230660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2011/11/deque-and-arraydeque.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/7100526573432230660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/7100526573432230660'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2011/11/deque-and-arraydeque.html' title='Deque and ArrayDeque'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-3143943573318938813</id><published>2011-11-21T10:35:00.001-08:00</published><updated>2011-11-21T10:46:26.714-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Collection API"/><category scheme="http://www.blogger.com/atom/ns#" term="Deque"/><category scheme="http://www.blogger.com/atom/ns#" term="Java 6.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Java technical tips"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA TIPS"/><category scheme="http://www.blogger.com/atom/ns#" term="New Feathers of Collection APIs"/><title type='text'>What&#39;s New in Java 6.0 Collection API</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;Here we have the new Collections APIs introduced in Java 6.0. There are few interesting changes in the Collections APIs, one amoung them is the Deque. Deque is used for the Bi-Directional traversal. It has different implementations including BlockingDeque,ArrayDeque,etc. Let&#39;s talk about the Deque and its various implementation,&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;&amp;nbsp;also few more changes in the Collectiona API in Java 6.0&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 13px;&quot;&gt;Following are the new collection APIs introduced in Java 6.0. And the list of Interfaces and classes are given below.&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;font-family: Verdana; font-size: 12px; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-top: 0px; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/h3&gt;
&lt;h3 style=&quot;font-family: Verdana; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-top: 0px; text-align: -webkit-auto;&quot;&gt;
New Interfaces:&lt;/h3&gt;
&lt;ul style=&quot;font-family: Verdana; font-size: 13px; text-align: -webkit-auto;&quot;&gt;
&lt;li&gt;Deque&lt;/li&gt;
&lt;li&gt;BlockingDeque&lt;/li&gt;
&lt;li&gt;NavigableSet&lt;/li&gt;
&lt;li&gt;NavigableMap&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: -webkit-auto;&quot;&gt;
&lt;h3 style=&quot;font-family: Verdana; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-top: 0px;&quot;&gt;
New Classes:&lt;/h3&gt;
&lt;ul style=&quot;font-family: Verdana; font-size: 13px;&quot;&gt;
&lt;li&gt;ArrayDeque&lt;/li&gt;
&lt;li&gt;LinkedBlockingDeque&lt;/li&gt;
&lt;li&gt;ConcurrentSkipListSet&lt;/li&gt;
&lt;li&gt;ConcurrentSkipListMap&lt;/li&gt;
&lt;li&gt;AbstractMap.SimpleEntry&lt;/li&gt;
&lt;li&gt;AbstractMap.SimpleImmutableEntry&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 12px;&quot;&gt;And following are the updated Classes in Java 6.0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;font-family: Verdana; font-size: 13px;&quot;&gt;
&lt;li&gt;LinkedList&lt;/li&gt;
&lt;li&gt;TreeSet&lt;/li&gt;
&lt;li&gt;TreeMap&lt;/li&gt;
&lt;li&gt;Collections&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: x-small;&quot;&gt;For more please visit-&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://download.oracle.com/javase/6/docs/technotes/guides/collections/index.html&quot;&gt;http://download.oracle.com/javase/6/docs/technotes/guides/collections/index.html&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/3143943573318938813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2011/11/whats-new-in-java-60-collection-api.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/3143943573318938813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/3143943573318938813'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2011/11/whats-new-in-java-60-collection-api.html' title='What&#39;s New in Java 6.0 Collection API'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-7925121600415556489</id><published>2011-09-23T01:37:00.000-07:00</published><updated>2011-09-23T01:38:31.850-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java technical tips"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA TIPS"/><category scheme="http://www.blogger.com/atom/ns#" term="Regular Expression"/><category scheme="http://www.blogger.com/atom/ns#" term="Replace word in a String"/><title type='text'>Simple Word Replacement From A String Using Regular Expression</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Here is a class which replace some words from a given string using Regular Expression.&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;/*
 * This code writes &quot;One dog, two dogs in the yard.&quot;
 * to the standard-output stream:
 */
import java.util.regex.*;

public class Replacement {
    public static void main(String[] args) 
                         throws Exception {
        // Create a pattern to match cat
        Pattern p = Pattern.compile(&quot;cat&quot;);
        // Create a matcher with an input string
        Matcher m = p.matcher(&quot;one cat,&quot; +
                       &quot; two cats in the yard&quot;);
        StringBuffer sb = new StringBuffer();
        boolean result = m.find();
        // Loop through and create a new String 
        // with the replacements
        while(result) {
            m.appendReplacement(sb, &quot;dog&quot;);
            result = m.find();
        }
        // Add the last segment of input to 
        // the new String
        m.appendTail(sb);
        System.out.println(sb.toString());
    }
}&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/7925121600415556489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2011/09/simple-word-replacement-from-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/7925121600415556489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/7925121600415556489'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2011/09/simple-word-replacement-from-string.html' title='Simple Word Replacement From A String Using Regular Expression'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-7080144818795173112</id><published>2011-09-23T00:24:00.000-07:00</published><updated>2011-09-23T00:29:53.773-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Comment line in Java"/><category scheme="http://www.blogger.com/atom/ns#" term="File in Java"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java technical tips"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA TIPS"/><category scheme="http://www.blogger.com/atom/ns#" term="Regular Expression"/><title type='text'>Search For Any Comment Line in a .java File Using Regular Expression</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;The following class searches for the line which are being commented in a file called &quot;Test.java&quot;.&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;/*
 * Prints out the comments found in a .java file.
 */
import java.util.regex.*;
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.nio.channels.*;

public class CharBufferExample {
    public static void main(String[] args) throws Exception {
        // Create a pattern to match comments
        Pattern p = 
            Pattern.compile(&quot;//.*$&quot;, Pattern.MULTILINE);
        
        // Get a Channel for the source file
        File f = new File(&quot;Test.java&quot;);
        FileInputStream fis = new FileInputStream(f);
        FileChannel fc = fis.getChannel();
        
        // Get a CharBuffer from the source file
        ByteBuffer bb = 
            fc.map(FileChannel.MAP_RO, 0, (int)fc.size());
        Charset cs = Charset.forName(&quot;8859_1&quot;);
        CharsetDecoder cd = cs.newDecoder();
        CharBuffer cb = cd.decode(bb);
        
        // Run some matches
        Matcher m = p.matcher(cb);
        while (m.find())
            System.out.println(&quot;Found comment: &quot;+m.group());
    }
}&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/7080144818795173112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2011/09/searching-any-comment-line-in-java-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/7080144818795173112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/7080144818795173112'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2011/09/searching-any-comment-line-in-java-file.html' title='Search For Any Comment Line in a .java File Using Regular Expression'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-6276778474030762537</id><published>2011-09-23T00:17:00.000-07:00</published><updated>2011-09-23T00:18:46.004-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Control character in java"/><category scheme="http://www.blogger.com/atom/ns#" term="File in Java"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java technical tips"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA TIPS"/><title type='text'>Removing Control Characters from a File Using Regular Expression</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif; font-size: small;&quot;&gt;Here we have a sample class which will remove all the control characters from a file.&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;/* This class removes control characters from a named
*  file.
*/
import java.util.regex.*;
import java.io.*;

public class Control {
    public static void main(String[] args) 
                                 throws Exception {
                                 
        //Create a file object with the file name
        //in the argument:
        File fin = new File(&quot;fileName1&quot;);
        File fout = new File(&quot;fileName2&quot;);
        //Open and input and output stream
        FileInputStream fis = 
                          new FileInputStream(fin);
        FileOutputStream fos = 
                        new FileOutputStream(fout);

        BufferedReader in = new BufferedReader(
                       new InputStreamReader(fis));
        BufferedWriter out = new BufferedWriter(
                      new OutputStreamWriter(fos));

	// The pattern matches control characters
        Pattern p = Pattern.compile(&quot;{cntrl}&quot;);
        Matcher m = p.matcher(&quot;&quot;);
        String aLine = null;
        while((aLine = in.readLine()) != null) {
            m.reset(aLine);
            //Replaces control characters with an empty
            //string.
            String result = m.replaceAll(&quot;&quot;);
            out.write(result);
            out.newLine();
        }
        in.close();
        out.close();
    }
}&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/6276778474030762537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2011/09/removing-control-characters-from-file.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/6276778474030762537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/6276778474030762537'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2011/09/removing-control-characters-from-file.html' title='Removing Control Characters from a File Using Regular Expression'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-4708083545731499777</id><published>2011-09-23T00:11:00.000-07:00</published><updated>2011-09-23T00:11:23.120-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java FINAL keyword"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA TIPS"/><title type='text'>Usage of &quot;Final&quot; keyword in Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
No matter how&amp;nbsp; often we use &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;final &lt;/span&gt;keyword in our Java program&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;/span&gt;, but we should use the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;final &lt;/span&gt;keyword liberally to communicate our intent.
&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
The final keyword has more than one meaning :
&lt;/div&gt;
&lt;ul style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;li&gt;
A &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;final &lt;/span&gt;class cannot be extended.&lt;/li&gt;
&lt;li&gt;
A &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;final &lt;/span&gt;method cannot be overridden.&lt;/li&gt;
&lt;li&gt;
A &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;final &lt;/span&gt;field, parameter and local variable cannot change their
value once set.&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
In the last case, &quot;value&quot; for primitives is understood in the usual sense,
while &quot;value&quot; for objects means the object&#39;s &lt;/span&gt;&lt;em style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;identity&lt;/em&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;, not its &lt;/span&gt;&lt;em style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;state&lt;/em&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;. Once
the identity of a final object reference is set, it can still
change its state, but not its identity.

&lt;/span&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
Declaring primitive fields as final automatically ensures thread-safety
for that field.
&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
Some habitually declare parameters as final, since this almost
always the desired behaviour. Others find this verbose, and of little real benefit.

&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
Consistently using final with local variables (when appropriate)
can be useful as well. It brings attention to the non-final local
variables, which usually have more logic associated with them (e.g:- result
variables, accumulators, loop variables). Many find this verbose.
A reasonable approach is to use final for local variables only if there is
at least one non-final local variable in the method ; this serves
to quickly distinguish the non-final local variables from the
others.
&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
So here have the advantages of using final :
&lt;/div&gt;
&lt;ul style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;li&gt;Clearly communicates your intent&lt;/li&gt;
&lt;li&gt;Allows the compiler and virtual machine to perform minor optimizations&lt;/li&gt;
&lt;li&gt;Clearly flags items which are simpler in behavior - final says,&amp;nbsp;
&quot;&lt;i&gt;If you are looking for complexity, you won&#39;t find it here.&lt;/i&gt;&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/4708083545731499777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2011/09/usage-of-final-keyword-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/4708083545731499777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/4708083545731499777'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2011/09/usage-of-final-keyword-in-java.html' title='Usage of &quot;Final&quot; keyword in Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-2587007096619248253</id><published>2011-09-18T10:08:00.000-07:00</published><updated>2011-09-18T10:37:25.244-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Connect to shared folder in Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Java technical tips"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA TIPS"/><title type='text'>Simplest Way To Connect To A Shared Folder in Windows With Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Sometimes we usually meet a situation like, we want to access a shared folder in windows environment remotely. So this is one of the simplest way to do so :-&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;lang-java prettyprint&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; margin-bottom: 10px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;typ&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;    File&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: darkblue; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&quot;\\\\theRemoteIP\\webapps&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;/code&gt; 
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;[]&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; files &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; file&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;listFiles&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&quot;Access granted&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &amp;nbsp;

&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: darkblue; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: darkblue; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; files&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;++)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; fname &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; files&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;(f&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/2587007096619248253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2011/09/simplest-way-to-connect-to-shared.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/2587007096619248253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/2587007096619248253'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2011/09/simplest-way-to-connect-to-shared.html' title='Simplest Way To Connect To A Shared Folder in Windows With Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4602628487645977758.post-2264727330972043575</id><published>2011-09-10T02:53:00.000-07:00</published><updated>2011-09-10T03:06:33.384-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Feature Of JDK 7"/><category scheme="http://www.blogger.com/atom/ns#" term="JDK 7"/><category scheme="http://www.blogger.com/atom/ns#" term="New in JDK 7"/><title type='text'>New Features Of JDK 7</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;189&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9J_uoBYkF0xXbse-QllnsnRg1zv_igcYVY8XY5bD7gFaMAKeT9yDD_ctzdMr5XerQ0eIVjQ_dnsLgA7wuEQ54X1pGACa1c-_fLRbIzFj5C88Y09Deg6bfvGG4dtUrVgdbr2kO13EZeRkX/s200/jdk7.jpg&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;With JDK 7 out the door, many writeups of the release have naturally focused on its larger features like Project Coin, NIO.2, the fork/join framework, and invokedynamic. However, there are a number of small but useful library conveniences in JDK 7 that shouldn&#39;t be overlooked.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;/div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;To allow more informative assertion errors to be constructed, AssertionError now includes a constructor taking a string message and a Throwable cause, which is one of the four conventional constructors for exception types.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The methods which convert strings to numeric values differed in whether or not a leading plus, &quot;+&quot;, was regarded as valid input. Float, Double, and BigDecimal accepted a leading plus while Byte, Short, Integer, Long, and BigInteger did not. As of JDK 7, all those types consistently accept a leading plus in their parseFoo, valueOf, and decode methods.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;To help write more efficient comparators, Boolean, Byte, Character, Short, Integer, and Long each have a two-argument static compare method that performs the desired comparison operation without boxing overhead.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This six checked exception types that can be thrown by core reflection now have a common supertype, ReflectiveOperationException. This additional type complements the improved exception handling available with multi-catch and more precise re-throw from Project Coin.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The java.util.Objects class contains a number of small, but commonly used methods, many of them for coping with null inputs. For example, Objects contains a two-argument static equals method which does the right thing on null inputs. I&#39;ve replaced a half-dozen copies of that method&#39;s logic in the JDK; I&#39;m sure many more instances can be removed in other code bases as JDK 7 is adopted.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Part of NIO.2, I expect over time the utility methods in java.nio.file.Files to copy, read, and write the contents of file will see heavy usage.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;And To recall, these are the list of feature which we discussed :-&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Modularity&lt;/span&gt;&lt;/li&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;li&gt;Multi-Language Support&lt;/li&gt;
&lt;li&gt;New Garbage Collector&lt;/li&gt;
&lt;li&gt;NIO.2 New File System API&lt;/li&gt;
&lt;li&gt;Additional Swing API&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;&lt;div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Visit For More @&amp;nbsp;&lt;a href=&quot;http://www.oracle.com/technetwork/java/javase/downloads/index.html&quot;&gt;http://www.oracle.com/technetwork/java/javase/downloads/index.html&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theageofjava.blogspot.com/feeds/2264727330972043575/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://theageofjava.blogspot.com/2011/09/new-features-of-jdk-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/2264727330972043575'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4602628487645977758/posts/default/2264727330972043575'/><link rel='alternate' type='text/html' href='http://theageofjava.blogspot.com/2011/09/new-features-of-jdk-7.html' title='New Features Of JDK 7'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9J_uoBYkF0xXbse-QllnsnRg1zv_igcYVY8XY5bD7gFaMAKeT9yDD_ctzdMr5XerQ0eIVjQ_dnsLgA7wuEQ54X1pGACa1c-_fLRbIzFj5C88Y09Deg6bfvGG4dtUrVgdbr2kO13EZeRkX/s72-c/jdk7.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>