<?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/opensearch/1.1/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;C0YEQXk4eCp7ImA9Wx9XEkQ.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263</id><updated>2011-01-05T21:18:20.730-08:00</updated><title>JAVA</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Nitin</name><email>nitins30@gmail.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;C0YEQXk4cCp7ImA9Wx9XEkQ.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-2914486155632436367</id><published>2011-01-05T21:17:00.000-08:00</published><updated>2011-01-05T21:18:20.738-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-01-05T21:18:20.738-08:00</app:edited><title>Business Process Modeling Notation (BPMN)</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Business Process Modeling Notation (BPMN)&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;Business Process Modeling Notation (BPMN) is a graphical representation for specifying the business process in a business process model.&lt;br /&gt;BPMN was developed by Business Process Management Initiative (BPMI) and Is currently maintained by the Object Management Group. The latest version of BPMN is 2.0. Business Process Modeling Notation is a graphical representation for specifying the business process in a business process model.&lt;br /&gt;BPM technology not only makes it easier for developers and analysts to model, implement and optimize a business process, but also makes it possible for operations and management to analyze the efficiency of the business process, and be informed of problems.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Elements:&lt;/span&gt;&lt;br /&gt;The modeling in BPMN is made by simple diagrams with a small set of graphical elements. It should make it easy for business users as well as developers to understand the flow and the process. The four basic categories of elements are as follows:&lt;br /&gt;Flow Objects&lt;br /&gt;Events, Activities, Gateways&lt;br /&gt;Connecting Objects&lt;br /&gt;Sequence Flow, Message Flow, Association&lt;br /&gt;Swimlanes&lt;br /&gt;Pool, Lane&lt;br /&gt;Artifacts&lt;br /&gt;Data Object, Group, Annotation&lt;br /&gt;&lt;br /&gt;The latest version of BPMN 2.0 (which is in beta) supports a formal met model for BPMN constructs and important constructs like conversations for correlating two processes , event handling (for suppresses and non interrupting events) and transactions and compensations.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Tools:&lt;/span&gt;&lt;br /&gt;Seam Framework&lt;br /&gt;This support jBPM for BPMN is an intuitive and powerful solution for enterprise applications with complex human collaboration, or web applications with complex user interactions.&lt;br /&gt;Seam deeply integrates jBPM and makes it incredibly simple to use jBPM for task management or pageflow, and is a great way to get started with BPM technology. The combination of Seam and jBPM can shrink development time of some kinds of projects by literally months for more details please refer http://seamframework.org/Seam2&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-2914486155632436367?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/2914486155632436367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2011/01/business-process-modeling-notation-bpmn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/2914486155632436367?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/2914486155632436367?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2011/01/business-process-modeling-notation-bpmn.html' title='Business Process Modeling Notation (BPMN)'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CkUNSX48fCp7ImA9Wx9QFk0.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-5269574208856585520</id><published>2010-12-28T21:24:00.000-08:00</published><updated>2010-12-28T21:24:58.074-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-12-28T21:24:58.074-08:00</app:edited><title>InfoQ: Estimation Toolkit</title><content type='html'>&lt;a href="http://www.infoq.com/articles/estimation-toolkit"&gt;InfoQ: Estimation Toolkit&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-5269574208856585520?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.infoq.com/articles/estimation-toolkit' title='InfoQ: Estimation Toolkit'/><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/5269574208856585520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/12/infoq-estimation-toolkit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/5269574208856585520?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/5269574208856585520?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/12/infoq-estimation-toolkit.html' title='InfoQ: Estimation Toolkit'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUcFQXsyeip7ImA9Wx9QFE4.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-8990476536039865160</id><published>2010-12-26T22:56:00.000-08:00</published><updated>2010-12-26T22:56:50.592-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-12-26T22:56:50.592-08:00</app:edited><title>InfoQ: Hades - JPA Repositories Done Right</title><content type='html'>&lt;a href="http://www.infoq.com/articles/hades_jpa_repositories_done_right"&gt;InfoQ: Hades - JPA Repositories Done Right&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-8990476536039865160?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.infoq.com/articles/hades_jpa_repositories_done_right' title='InfoQ: Hades - JPA Repositories Done Right'/><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/8990476536039865160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/12/infoq-hades-jpa-repositories-done-right.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/8990476536039865160?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/8990476536039865160?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/12/infoq-hades-jpa-repositories-done-right.html' title='InfoQ: Hades - JPA Repositories Done Right'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;A0AAQ346eyp7ImA9Wx5WF04.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-290161211892595185</id><published>2010-09-28T22:55:00.000-07:00</published><updated>2010-09-28T22:55:42.013-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-09-28T22:55:42.013-07:00</app:edited><title>Java Barcode API</title><content type='html'>&lt;a href="http://www.vineetmanohar.com/2010/09/java-barcode-api/"&gt;Java Barcode API&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-290161211892595185?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.vineetmanohar.com/2010/09/java-barcode-api/' title='Java Barcode API'/><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/290161211892595185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/09/java-barcode-api.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/290161211892595185?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/290161211892595185?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/09/java-barcode-api.html' title='Java Barcode API'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DEQCRnc9fCp7ImA9Wx5WEEo.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-4046830892754460289</id><published>2010-09-21T06:39:00.000-07:00</published><updated>2010-09-21T06:39:27.964-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-09-21T06:39:27.964-07:00</app:edited><title>InfoQ: Introducing the Tellurium Automated Testing Framework</title><content type='html'>&lt;a href="http://www.infoq.com/articles/tellurium_intro"&gt;InfoQ: Introducing the Tellurium Automated Testing Framework&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-4046830892754460289?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.infoq.com/articles/tellurium_intro' title='InfoQ: Introducing the Tellurium Automated Testing Framework'/><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/4046830892754460289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/09/infoq-introducing-tellurium-automated.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/4046830892754460289?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/4046830892754460289?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/09/infoq-introducing-tellurium-automated.html' title='InfoQ: Introducing the Tellurium Automated Testing Framework'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;D08BR3c_fip7ImA9Wx5WEEg.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-3610732767420148290</id><published>2010-09-21T00:56:00.000-07:00</published><updated>2010-09-21T00:57:36.946-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-09-21T00:57:36.946-07:00</app:edited><title>Java Kicks Ruby on Rails in the Butt</title><content type='html'>&lt;blockquote&gt;&lt;a href="http://eclipse.sys-con.com/node/965189"&gt;Java Kicks Ruby on Rails in the Butt&lt;/a&gt;&lt;br /&gt;— “What would you think if I told you that you can develop a web application at least ten times faster with Rails than you can with a typical Java framework?” Oops! Ten times faster! Well, after these comments I decided to learn Ruby on Rails. I need to know the true key of the productivity and programmer happiness.&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-3610732767420148290?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/3610732767420148290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/09/java-kicks-ruby-on-rails-in-butt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/3610732767420148290?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/3610732767420148290?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/09/java-kicks-ruby-on-rails-in-butt.html' title='Java Kicks Ruby on Rails in the Butt'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUQBRH09fSp7ImA9Wx5QGU4.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-9152532718312809830</id><published>2010-09-08T01:06:00.000-07:00</published><updated>2010-09-08T01:09:15.365-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-09-08T01:09:15.365-07:00</app:edited><title>Class member variable initialization</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cnitin%5CLocal%20Settings%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	mso-bidi-font-size:11.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	color:black; 	mso-fareast-language:EN-US;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p style="color: rgb(0, 0, 0);" class="MsoNormal"&gt;&lt;span style="font-size: 10pt;"&gt;While declaring the class member variables we have to be very confident about the behavior of the member variables. For example some variable are constant and will be same across the class life cycle and some are instance variables which will be tightly bind with the object (instance) of the class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="color: rgb(0, 0, 0);" class="MsoNormal"&gt;&lt;span style="font-size: 10pt;"&gt;When &lt;a name="Sample1"&gt;an instance of a class is created using &lt;/a&gt;&lt;/span&gt;&lt;span style=""&gt;new&lt;/span&gt;&lt;span style=""&gt;&lt;span style="font-size: 10pt;"&gt;, initialization of the class's instance variables create for each unique instance.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="color: rgb(0, 0, 0);" class="MsoNormal"&gt;&lt;span style="font-size: 10pt;"&gt;Always use the static for the member variable which doesn’t change across the objects of the class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="color: rgb(0, 0, 0);" class="MsoNormal"&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 51, 102);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I would try to check the performance using the below code sample:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cnitin%5CLocal%20Settings%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="country-region"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"&gt;&lt;/object&gt; &lt;style&gt; st1\:*{behavior:url(#ieooui) } &lt;/style&gt; &lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	mso-bidi-font-size:11.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	color:black; 	mso-fareast-language:EN-US;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; TestClassVariable {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; TestClassVariable() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);"&gt;// do nothing&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; String &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;country&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;[] = { &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"&lt;st1:country-region st="on"&gt;India&lt;/st1:country-region&gt;"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;, &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"&lt;st1:country-region st="on"&gt;USA&lt;/st1:country-region&gt;"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;, &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"&lt;st1:country-region st="on"&gt;China&lt;/st1:country-region&gt;"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;, &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"&lt;st1:place st="on"&gt;&lt;st1:country-region st="on"&gt;UK&lt;/st1:country-region&gt;&lt;/st1:place&gt;"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; };&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; main(String s[]) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; start, end;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;[] a = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;[1000000];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;start = System.&lt;i&gt;currentTimeMillis&lt;/i&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; (&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; j = 0; j &lt;&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;length&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;; j++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;                  &lt;/span&gt;TestClassVariable &lt;u&gt;tstClassVar&lt;/u&gt; = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; TestClassVariable();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;end = System.&lt;i&gt;currentTimeMillis&lt;/i&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;System.&lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;.println(end - start + &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;" "&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;                        &lt;/span&gt;+ &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;" milli seconds execution time"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;Result: 94 milli seconds execution time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cnitin%5CLocal%20Settings%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	mso-bidi-font-size:11.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	color:black; 	mso-fareast-language:EN-US;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p style="color: rgb(0, 0, 0);" class="MsoNormal"&gt;&lt;span style="font-size: 10pt;"&gt;In the above code we used country as class instance variable and it takes 94MS but as we know country could be make as static member variable because it will be not going to change across the instances so the correct way to use as static member variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; color: rgb(0, 51, 102);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;So we can change the program slightly and see the figures again&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style="font-size: 10pt; color: rgb(0, 51, 102);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cnitin%5CLocal%20Settings%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="country-region"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"&gt;&lt;/object&gt; &lt;style&gt; st1\:*{behavior:url(#ieooui) } &lt;/style&gt; &lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	mso-bidi-font-size:11.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	color:black; 	mso-fareast-language:EN-US;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; TestClassVariable {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; TestClassVariable() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);"&gt;// do nothing&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="background: silver none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;String&lt;/span&gt; &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;country&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;[] = { &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"&lt;st1:country-region st="on"&gt;India&lt;/st1:country-region&gt;"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;, &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"&lt;st1:country-region st="on"&gt;USA&lt;/st1:country-region&gt;"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;, &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"&lt;st1:country-region st="on"&gt;China&lt;/st1:country-region&gt;"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;, &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;"&lt;st1:place st="on"&gt;&lt;st1:country-region st="on"&gt;UK&lt;/st1:country-region&gt;&lt;/st1:place&gt;"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; };&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;static&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; main(&lt;span style="background: silver none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;String&lt;/span&gt; s[]) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; start, end;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;[] a = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;[1000000];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;start = System.&lt;i&gt;currentTimeMillis&lt;/i&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; (&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; j = 0; j &lt;&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;length&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;; j++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;                  &lt;/span&gt;TestClassVariable &lt;u&gt;tstClassVar&lt;/u&gt; = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; TestClassVariable();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;end = System.&lt;i&gt;currentTimeMillis&lt;/i&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;System.&lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;out&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;.println(end - start + &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;" "&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;                        &lt;/span&gt;+ &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);"&gt;“milli seconds execution time"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;Result: 16 milli seconds execution time&lt;/span&gt;&lt;/p&gt;  &lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cnitin%5CLocal%20Settings%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	mso-bidi-font-size:11.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	color:black; 	mso-fareast-language:EN-US;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 0);"&gt;We could easily figure it out the performance get enhance 6 times then the original one&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 10pt; font-family: Arial; color: rgb(0, 51, 102);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-9152532718312809830?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/9152532718312809830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/09/class-member-variable-initialization.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/9152532718312809830?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/9152532718312809830?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/09/class-member-variable-initialization.html' title='Class member variable initialization'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DEEBQX08fCp7ImA9Wx5QF0s.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-8619427191443735773</id><published>2010-09-06T02:44:00.000-07:00</published><updated>2010-09-06T02:50:50.374-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-09-06T02:50:50.374-07:00</app:edited><title>Calling object inside the loop</title><content type='html'>We could use to create the object inside or outside of the loop depends upon the behavior of the class.&lt;br /&gt;If any class having class member variable then class needs to be inside the loop and that will limit their scope which is good to garbage collect but if class used as Utility class and doesn’t have member class variable then we could declare the class out side of the loop and used inside the loop.&lt;br /&gt;Below example shows there are only 32 ms would take to instantiate the object inside the loop but best thing is that it would limit the scope which is good during garbage collection&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;public class TestLoop {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    public static void main(String s[]) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        long start, end;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        int[] a = new int[1000000];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        start = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        TestName tname1 = new TestName();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        for (int i = 0; i &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            // tname1=new TestName();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        end = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        System.out.println(end - start + " milli "&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            + “seconds for One Time Loop");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        start = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        for (int j = 0; j &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            TestName tname = new TestName();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        end = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        System.out.println(end - start + " "&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            + “milli seconds loop calling object inside Loop ");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Result: 0 milli seconds for One Time Loop&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;32 milli seconds for loop calling object inside Loop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;As per above example you could see the declaring the object inside loop doesn’t have much impact on performance.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;In below example explain the two ways to declare the object option 1 inside declaration and option 2 out side declaration.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Option 1:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int i=0; i&lt;intlmtval;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Object obj = tempList.get(i);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    o. doOperation();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Option 2:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Object o;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int i=0; i&lt;intlmtval;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    o = tempList.get(i);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    o.doOperation();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;We could say that Option1 better as it restricts scope of ‘obj’ variable to the for block. From a performance perspective, it might not have any effects in Java, but it might have in lower level compilers. They might put the variable in a register if you do the first.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Construction of an object using new is totally different from just declaring it, of course.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I think readability is more important than performance and from a readability standpoint, the first code is definitely better.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;But if you have utility class which doesn’t have member variables we could instantiate once and reuse across the code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;In the below example I am trying to explain the utility class which could be instantiate once and use across the application.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;import java.util.Calendar;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;import java.util.Date;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;public class TestLoop {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    public static void main(String s[]) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        long start, end;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        int[] a = new int[1000000];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        Calendar cal = Calendar.getInstance();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        start = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        for (int i = 0; i &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            Date dt = cal.getTime();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        end = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        System.out.println(end - start + " milli "&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        + "seconds for Instantiating object out side Loop");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        start = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        TestName tname = null;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        for (int j = 0; j &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            Date dt = Calendar.getInstance().getTime();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        end = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        System.out.println(end - start + " "&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        + "milli seconds Instantiating object inside Loop ");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-style: italic;"&gt;0 milli seconds for Instantiating object out side Loop&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-style: italic;"&gt;797 milli seconds Instantiating object inside Loop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/intlmtval;&gt;&lt;/span&gt;&lt;/intlmtval;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-8619427191443735773?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/8619427191443735773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/09/calling-object-inside-loop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/8619427191443735773?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/8619427191443735773?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/09/calling-object-inside-loop.html' title='Calling object inside the loop'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Dk8GRn8zeyp7ImA9Wx5QEk4.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-1089227775405783476</id><published>2010-08-30T22:42:00.000-07:00</published><updated>2010-08-30T23:07:07.183-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-08-30T23:07:07.183-07:00</app:edited><title>Avoid Nested Loop</title><content type='html'>Nested loop gives big impact on performance and some time it make worse if not controlled properly. Need to double think before using the nested loop and try to find some alternative way to handle the same. Even if it is used, it should not go to level three in nested loop.&lt;br /&gt;It is explained in the below code.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;public class TestLoop {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;public static void main(String s[]) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;long start, end;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;int[] a = new int[100000];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;int[] b = new int[100000];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;start = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int i = 0; i &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;end = System.currentTimeMillis(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;System.out.println(end - start + " " + "milli seconds for One Time Loop"); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;start = System.currentTimeMillis(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int j = 0; j &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int i = 0; i &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;end = System.currentTimeMillis(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;System.out.println(end - start + " " + "milli seconds for loop B inside Loop A"); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;} &lt;/span&gt;&lt;br /&gt;Result:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;0 milli seconds for One Time Loop &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;44015 milli seconds for loop B inside Loop A  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;You can see the above result how it becomes 44015 ms for executing the loop inside the loop. These are figure for just an empty loop. For any process getting invoked inside the nested loop, the time will be exorbitantly increase..  I would suggest you to think before using the nesting loop with large data and try to avoid as much as possible. You could try to change/write a code in such a way that it would minimize the nested loop.  It is explained using the below code. In the below code I am trying to match the value in a big array and print the ‘Found match’ on the console. &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;public class TestLoop {  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;public static void main(String s[]) {  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;long start, end;  String[] arrFirst = new String[1000000];  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;String[] arrSecond = { "0", "1" };  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int i = 0; i &lt;&gt;length; i++) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;arrFirst[i] = String.valueOf(i);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;start = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int i = 0; i &lt;&gt;length; i++) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int j = 0; j &lt;&gt;length; j++) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;if (arrFirst[i].equalsIgnoreCase(arrSecond[j])) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;System.out.println("Found match");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;end = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;System.out.println(end - start + " milli "+ "seconds for ");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;start = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;Result: 30 ms&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;As you can see that it iterate the 1000000*2 times to complete the process. Since we know arrSecond having only two values 0 and 1 therefore we could easily minimize the code using below way&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;public class TestLoop1 {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;public static void main(String s[]) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;long start, end;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;String[] arrFirst = new String[1000000];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;String[] arrSecond = { "0", "1" };&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int i = 0; i &lt;&gt;length; i++) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;arrFirst[i] = String.valueOf(i);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;start = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;for (int i = 0; i &lt;&gt;length; i++) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;if ((arrSecond[0].equalsIgnoreCase(arrFirst[i]))|| (arrSecond[1].equalsIgnoreCase(arrFirst[i]))) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;System.out.println("Found match");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;end = System.currentTimeMillis();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;System.out.println(end - start + " milli "+ "seconds for loop");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Result: 15 ms&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;You could see it just iterate 1000000 times just half the above code and performance get improved twice.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I agree that this is not the best example but this would definitely provide you the way how to handle the nested loop&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-1089227775405783476?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/1089227775405783476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/08/avoid-nested-loop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/1089227775405783476?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/1089227775405783476?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/08/avoid-nested-loop.html' title='Avoid Nested Loop'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Dk8NRHk8cCp7ImA9Wx5QEk4.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-1303856688315626149</id><published>2010-08-30T02:48:00.000-07:00</published><updated>2010-08-30T23:08:15.778-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-08-30T23:08:15.778-07:00</app:edited><title>Java Loop</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Loop&lt;/span&gt;&lt;br /&gt;Loops provide efficient way for repeating a piece of code as many times as required. Java has three ways to use the loop control structures and these are:&lt;br /&gt;&lt;br /&gt;For Loop: The ‘For-Loop’ is used when we know in advance how many iteration is required&lt;br /&gt;While Loop: The while loop is used when we do not know in advance the number of iterations required so each time before entering the loop the condition is checked and if it is true then the loop get executed&lt;br /&gt;Do-While Loop: The do-while loop is always executed at least once and then the condition is checked at the end of the loop. Developer has to avoid using the do-while loop since it marks major bottleneck in the code.&lt;br /&gt;&lt;br /&gt;Since loop repeats the piece of code therefore it gives more cause for performance and need to be very careful during the implementation&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-1303856688315626149?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/1303856688315626149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/08/java-performace-concepts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/1303856688315626149?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/1303856688315626149?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/08/java-performace-concepts.html' title='Java Loop'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;C0YMRXw6eyp7ImA9Wx5QEUs.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-133127955822414599</id><published>2010-08-30T02:38:00.000-07:00</published><updated>2010-08-30T02:39:44.213-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-08-30T02:39:44.213-07:00</app:edited><title>Nice one</title><content type='html'>Today i gone through the for some article and found really its useful&lt;br /&gt;http://www.infoq.com/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-133127955822414599?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/133127955822414599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/08/nice-one.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/133127955822414599?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/133127955822414599?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/08/nice-one.html' title='Nice one'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;Ck8BRH49fyp7ImA9Wx5QEUs.&quot;'><id>tag:blogger.com,1999:blog-8686478924646582263.post-8158014545204577391</id><published>2010-08-30T02:31:00.000-07:00</published><updated>2010-08-30T02:34:15.067-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-08-30T02:34:15.067-07:00</app:edited><title>First Blogging</title><content type='html'>I heard and many time about blogging and also i used to read the blogging but first time i will be going to write. Really internet is now revolution of human kind some years no one thought about it. I could remember when the internet bubble blast  and we though that it is the end of internet.&lt;br /&gt;When i started my career i never believe on internet power i always thought that it could never be successful. But not only me everyone believe.&lt;br /&gt;The technology is changing drastically and its growing exponentially and i could imagine still its just now started.&lt;br /&gt;We could hope that we will see some more wonder in future.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8686478924646582263-8158014545204577391?l=krnitin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krnitin.blogspot.com/feeds/8158014545204577391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://krnitin.blogspot.com/2010/08/first-blogging.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/8158014545204577391?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8686478924646582263/posts/default/8158014545204577391?v=2'/><link rel='alternate' type='text/html' href='http://krnitin.blogspot.com/2010/08/first-blogging.html' title='First Blogging'/><author><name>Nitin</name><email>nitins30@gmail.com</email><gd:extendedProperty name='OpenSocialUserId' value='01844307331270276615'/></author><thr:total>0</thr:total></entry></feed>