<?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-5879038844944713475</id><updated>2026-10-07T00:19:12.252-07:00</updated><category term="JAVA CODE SPOT : Java Programming Course"/><category term="JAVA CODE SPOT : Analog Clock"/><category term="JAVA CODE SPOT : Calendar"/><category term="JAVA CODE SPOT : Flickering Problem Solved"/><category term="JAVA CODE SPOT : Font Formatter"/><category term="JAVA CODE SPOT : Music Player"/><category term="JAVA CODE SPOT : Painting Application"/><category term="JAVA CODE SPOT : Scrollbar Animation"/><category term="JAVA CODE SPOT : Sorting Animations"/><category term="JAVA CODE SPOT : Typing Test"/><category term="JAVA CODE SPOT : Version Checker"/><category term="JAVA CODE SPOT : Welocme"/><title type='text'>JAVA CODE SPOT</title><subtitle type='html'>Useful Java source code and java examples for the beginners and programmers.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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>33</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-2739401619138186553</id><published>2012-04-04T10:13:00.003-07:00</published><updated>2012-04-04T10:18:56.870-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : String Class</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA String&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;In Java there is eight &lt;a href=&quot;http://javacodespot.blogspot.in/2011/03/java-programming-data-types.html&quot; target=&quot;_blank&quot;&gt;primitive data type&lt;/a&gt;&amp;nbsp;and also a special &lt;b&gt;String class&lt;/b&gt; in &lt;i&gt;java.lang.string&lt;/i&gt; package for string handling.&lt;br /&gt;
String are like sequence of characters.&amp;nbsp;String is not a primitive data type (because strings are objects) but the java language provides some special support to strings so, sometimes its seems like Strings are one of the primitive type.&lt;br /&gt;
String are very&amp;nbsp;widely&amp;nbsp;used in java and if you ever done some programming in Java than you must have created &amp;nbsp;a string in some way or the other. &lt;br /&gt;
For example the most direct way to create an String object is by just enclosing some characters in&amp;nbsp;double quotes(&quot;&quot;).&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; String&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;This is a String&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
String is an object in java so it can also be declared as any other object is declared using new keyword.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;String &lt;span style=&quot;color: blue;&quot;&gt;str &lt;/span&gt;= &lt;b&gt;&lt;span style=&quot;color: #990000;&quot;&gt;new &lt;/span&gt;&lt;/b&gt;String();&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
String class has several constructors to create a String object. The above example is one of the way simplest way to create an string. The constructor used in the example is a no argument constructor or we can say a default constructor which will create a empty String i.e. &lt;i&gt;str&lt;/i&gt; will be an instance of String with no character in it.&lt;br /&gt;
Below is an example which show a number of ways to create a String object.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;StringExample&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;this&amp;nbsp;is&amp;nbsp;will&amp;nbsp;create&amp;nbsp;an&amp;nbsp;empty&amp;nbsp;String&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;str&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;Creating&amp;nbsp;a&amp;nbsp;String&amp;nbsp;using&amp;nbsp;an&amp;nbsp;character&amp;nbsp;array&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;char&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ch&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;J&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;a&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;v&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;a&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;C&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;o&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;d&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;e&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;S&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;p&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;o&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;t&#39;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;strChar&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ch&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;Creating&amp;nbsp;a&amp;nbsp;String&amp;nbsp;from&amp;nbsp;character&amp;nbsp;array&#39;s&amp;nbsp;subarray&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//in&amp;nbsp;arguments&amp;nbsp;give&amp;nbsp;the&amp;nbsp;source&amp;nbsp;character&amp;nbsp;array,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//starting&amp;nbsp;point&amp;nbsp;and&amp;nbsp;number&amp;nbsp;of&amp;nbsp;character&amp;nbsp;after&amp;nbsp;that&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;strSubChar&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ch,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Creating&amp;nbsp;an&amp;nbsp;array&amp;nbsp;using&amp;nbsp;byte&amp;nbsp;array&amp;nbsp;of&amp;nbsp;ASCII&amp;nbsp;Value&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;byte&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;74&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;65&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;86&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;65&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;strByte&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Just&amp;nbsp;like&amp;nbsp;character&amp;nbsp;array&amp;nbsp;we&amp;nbsp;can&amp;nbsp;also&amp;nbsp;create&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//string&amp;nbsp;form&amp;nbsp;subarray&amp;nbsp;of&amp;nbsp;byte&amp;nbsp;array&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;strByteSub&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;strChar&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;strSubChar&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;strByte&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;strByteSub&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Output of Program:&lt;/u&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2UIokBo8N9uvhD2uBCYftoaoFLh1Q1zHUKIwS7DV0H0iRLG5gf2ZuETictff7511VZ19F57Ogd23jP_0JXKhF3hvdhCWD1f9RtfFcnGo4UVv8gwYhWnxFTiuanWotKQN5X1SLhakY1jQ/s1600/String.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2UIokBo8N9uvhD2uBCYftoaoFLh1Q1zHUKIwS7DV0H0iRLG5gf2ZuETictff7511VZ19F57Ogd23jP_0JXKhF3hvdhCWD1f9RtfFcnGo4UVv8gwYhWnxFTiuanWotKQN5X1SLhakY1jQ/s1600/String.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
There are some more String Constructors but we will&amp;nbsp;discusses them in later tutorials.&lt;br /&gt;
&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Methods of String Class:-&lt;/u&gt;&amp;nbsp;String class provides&amp;nbsp;several methods for string manipulation and these are going to be very useful in many situation like&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;Input validation, text analysis and file conversions&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;etc. In this tutorial we are going to&amp;nbsp;discuses&amp;nbsp;most of the common methods of String class.&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;public charAt(int index) :- &amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public int length() :-&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public String concat(String s) :-&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public boolean equals(String s)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public boolean equalsIgnoreCase(String s)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public String substring(int begin)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public String substring(int begin,int end)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public String toLowerCase()&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public String toUpperCase()&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public String trim()&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public int indexOf(int ch)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public int indexOf(int ch, int startIndex)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public int indexOf(String str)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;public int indexOf(String str, int startIndex)&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;/ul&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/2739401619138186553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2012/04/string-class.html#comment-form' title='22 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2739401619138186553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2739401619138186553'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2012/04/string-class.html' title='JAVA Programming : String Class'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEg2UIokBo8N9uvhD2uBCYftoaoFLh1Q1zHUKIwS7DV0H0iRLG5gf2ZuETictff7511VZ19F57Ogd23jP_0JXKhF3hvdhCWD1f9RtfFcnGo4UVv8gwYhWnxFTiuanWotKQN5X1SLhakY1jQ/s72-c/String.JPG" height="72" width="72"/><thr:total>22</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-379011391579402747</id><published>2012-01-29T02:34:00.000-08:00</published><updated>2012-01-29T02:35:05.384-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Factorial</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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA Factorial&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Factorial is a&amp;nbsp;mathematical operation&amp;nbsp;Factorial of a positive number &lt;i&gt;n&lt;/i&gt;&amp;nbsp;is denoted by&amp;nbsp;&lt;i&gt;n! &lt;/i&gt;and defined as the product of all numbers from 1 to the n. The syntax of factorial of number &lt;b style=&quot;font-style: italic;&quot;&gt;n&lt;/b&gt;&amp;nbsp;is:&lt;/div&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; n! =&amp;nbsp;n*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;n-&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;n-&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;n-&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;......2*&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1 &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;For Example:-&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span style=&quot;line-height: 20px; white-space: normal;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;7!&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 20px; white-space: normal;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;= 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Note:-&lt;/u&gt;&amp;nbsp;Factorial of zero is 1 (i.e. 0! = 1).&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Factorial&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fact&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fact&amp;nbsp;=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;=&amp;nbsp;n;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fact=fact*i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fact;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Factorial&amp;nbsp;f&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Factorial&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;a&amp;nbsp;Nu4mber&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;result&amp;nbsp;=&amp;nbsp;f.fact&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Facotial&amp;nbsp;of&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+num+&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;is&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+result&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Output of Program:-&lt;/u&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEJolE5C-Cv3qgRpAN13lVOfOuuwx8bQzutHA3j8bkZeKixZgC6G7Sfn5fH620U_oppQ04JFowlAqv6WRJYS2KmTHWITEmnU3Vgfj2SZa95MG5LG_6YZm99xBPw1xZ01Or3YTRBeyA1Sg/s1600/factorial+java.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEJolE5C-Cv3qgRpAN13lVOfOuuwx8bQzutHA3j8bkZeKixZgC6G7Sfn5fH620U_oppQ04JFowlAqv6WRJYS2KmTHWITEmnU3Vgfj2SZa95MG5LG_6YZm99xBPw1xZ01Or3YTRBeyA1Sg/s1600/factorial+java.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/379011391579402747/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2012/01/factorial-java.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/379011391579402747'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/379011391579402747'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2012/01/factorial-java.html' title='JAVA Programming : Factorial'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEjEJolE5C-Cv3qgRpAN13lVOfOuuwx8bQzutHA3j8bkZeKixZgC6G7Sfn5fH620U_oppQ04JFowlAqv6WRJYS2KmTHWITEmnU3Vgfj2SZa95MG5LG_6YZm99xBPw1xZ01Or3YTRBeyA1Sg/s72-c/factorial+java.JPG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-2842799524173464398</id><published>2012-01-27T09:05:00.000-08:00</published><updated>2012-01-28T10:13:13.149-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Pyramids 2</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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA Pyramids 2&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;In the &lt;a href=&quot;http://javacodespot.blogspot.com/2012/01/java-programming-pyramids.html&quot; target=&quot;_blank&quot;&gt;previous post&lt;/a&gt; we have&amp;nbsp;discussed&amp;nbsp;about different pyramids examples and we will continue to do some more examples. In this tutorial I will post the code of some more complex pyramid examples.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*****&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*******&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;*********&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Code for this program:-&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Pyramid&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;the&amp;nbsp;length&amp;nbsp;of&amp;nbsp;pyramid&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;rows&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------Output------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;=&amp;nbsp;rows;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&amp;nbsp;=&amp;nbsp;rows-&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;j&amp;nbsp;&amp;gt;=&amp;nbsp;i;&amp;nbsp;j--&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;k&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;k&amp;nbsp;&amp;lt;=&amp;nbsp;i;&amp;nbsp;k++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;l =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; l &amp;lt;=&amp;nbsp;i; l++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------------------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Output of Program:-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiouTHqa_z2etIceg5P7wLvRRI8L3uiUGd0v9K6dswjBC4s_w20jHv9-ePqWnDISx7kSbiGe6caoKYg-Afchs1F1NtAsduPK224hYBk-l1Yx3SOo-caBa-Srqif1ZYY_p3puk54jL9t6aw/s1600/Pyramid+Asterisks.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiouTHqa_z2etIceg5P7wLvRRI8L3uiUGd0v9K6dswjBC4s_w20jHv9-ePqWnDISx7kSbiGe6caoKYg-Afchs1F1NtAsduPK224hYBk-l1Yx3SOo-caBa-Srqif1ZYY_p3puk54jL9t6aw/s1600/Pyramid+Asterisks.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ************ &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; *****&amp;nbsp;&amp;nbsp;*****&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ****&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;****&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; *** &amp;nbsp; &amp;nbsp; &amp;nbsp;***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&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;br /&gt;
&lt;span style=&quot;color: black;&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;*&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Code for this Program:-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Pyramid&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;the&amp;nbsp;length&amp;nbsp;of&amp;nbsp;pyramid&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;rows&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------Output------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;=&amp;nbsp;rows;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&amp;nbsp;=&amp;nbsp;rows;&amp;nbsp;j&amp;nbsp;&amp;gt;=&amp;nbsp;i;&amp;nbsp;j--&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;k&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;k&amp;nbsp;&amp;lt;=&amp;nbsp;i;&amp;nbsp;k++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;l&amp;nbsp;=&amp;nbsp;rows;&amp;nbsp;l&amp;nbsp;&amp;gt;=&amp;nbsp;i;&amp;nbsp;l--&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------------------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Output of Program:-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2I4n_7O6aVOXU1SHUaA6f_-DsF40JL8WoFNjALCx37aPc7ZX2OPbFEpRLewS4emdHH0TDalPXPM_QGmS6Cv_p-_9SJXLbjNOpqQYDNlTEreXZzugXPJnOi8dR3bxKUVo5oMIZyrYNftw/s1600/Asterisks+Pyramid.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2I4n_7O6aVOXU1SHUaA6f_-DsF40JL8WoFNjALCx37aPc7ZX2OPbFEpRLewS4emdHH0TDalPXPM_QGmS6Cv_p-_9SJXLbjNOpqQYDNlTEreXZzugXPJnOi8dR3bxKUVo5oMIZyrYNftw/s1600/Asterisks+Pyramid.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;************ &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;*****&amp;nbsp;&amp;nbsp;*****&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;****&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;****&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;***&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&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;br /&gt;
&lt;span style=&quot;color: black;&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;*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&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;*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&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;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;***&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;****&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;****&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;*****&amp;nbsp;&amp;nbsp;*****&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;************&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Code for this Program:-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNSlIJO0oxp_TxMb3sDspSV7Gfiib_8Wlo6TuV03mtepnBmsnlKCmPOIqFIL2OdCBkjAY19m5Bq2ISrtS_Fxj3xJr-uJPu-FfgnwBXfWFV48abJXbQGuLbuqRdfYdcnBl9SOr_UZZWyXE/s1600/Mirror+pyramid.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNSlIJO0oxp_TxMb3sDspSV7Gfiib_8Wlo6TuV03mtepnBmsnlKCmPOIqFIL2OdCBkjAY19m5Bq2ISrtS_Fxj3xJr-uJPu-FfgnwBXfWFV48abJXbQGuLbuqRdfYdcnBl9SOr_UZZWyXE/s1600/Mirror+pyramid.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/2842799524173464398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2012/01/java-programming-pyramids-2.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2842799524173464398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2842799524173464398'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2012/01/java-programming-pyramids-2.html' title='JAVA Programming : Pyramids 2'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEiouTHqa_z2etIceg5P7wLvRRI8L3uiUGd0v9K6dswjBC4s_w20jHv9-ePqWnDISx7kSbiGe6caoKYg-Afchs1F1NtAsduPK224hYBk-l1Yx3SOo-caBa-Srqif1ZYY_p3puk54jL9t6aw/s72-c/Pyramid+Asterisks.JPG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-1028582091830425412</id><published>2012-01-26T06:40:00.000-08:00</published><updated>2012-01-29T03:33:09.100-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Pyramids</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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA Pyramids&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;In the last few tutorials we have&amp;nbsp;discussed&amp;nbsp;some basic concepts of&amp;nbsp;programming and in next few posts we will be using them to make some simple programs.&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Pyramids are very common examples that I think every programmer had made at the time of start learning programming. Pyramids are very useful in teaching the use of loops. There are&amp;nbsp;numerous&amp;nbsp;types of pyramids example. Lets start with an basic example.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;**&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;
&lt;/u&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Creating the Pyramid Program:-&lt;/u&gt;&amp;nbsp;We will make an simple program that will take an integer input from user and print the asterisks pyramid with that much number of rows.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Pyramid&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;the&amp;nbsp;length&amp;nbsp;of&amp;nbsp;pyramid&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;rows&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------Output------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;=&amp;nbsp;rows;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;j&amp;nbsp;&amp;lt;=&amp;nbsp;i;&amp;nbsp;j++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------------------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In this program, first we take an integer input form user using &lt;a href=&quot;http://javacodespot.blogspot.com/2011/04/java-programming-using-scanner-for-user.html&quot; target=&quot;_blank&quot;&gt;Scanner&lt;/a&gt; class&amp;nbsp;and than nested for loop is declared (i.e. a loop inside another loop). In this the outer for loop will run the same number of times as enter by user(from 1 to the enter number) and after every iteration it will print a new row and increment the loop control variable by 1. Inside the outer loop a new&amp;nbsp;inner for loop is declared which will print the same number of&amp;nbsp;asterisk as the current iteration value of outer loop control variable.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;Output of Program:-&lt;/u&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhQfxpiz7JkATTMDbsLuPzrAn27NcF8KPhGudZv9ofsqkt8vbxuPN4-VGk5SZ1MvPqlPlK47AM-qBsWAsHtLBtx62OWB08obTFi27bErWUDYx_iU55IW_Y4TyATjOQCWOAvQw5O6oG9Lo/s1600/JavaPyramid.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhQfxpiz7JkATTMDbsLuPzrAn27NcF8KPhGudZv9ofsqkt8vbxuPN4-VGk5SZ1MvPqlPlK47AM-qBsWAsHtLBtx62OWB08obTFi27bErWUDYx_iU55IW_Y4TyATjOQCWOAvQw5O6oG9Lo/s1600/JavaPyramid.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;b&gt;Reverse Pyramid: &lt;/b&gt;The next program we will be making is to print a reverse pyramid. The reverse pyramid will look like:-&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ***** &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ****&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ***&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; **&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
The code for printing a reverse pyramid is not very different from the&amp;nbsp;previous&amp;nbsp;one.&amp;nbsp;Infact&amp;nbsp;we can actually do it just by changing one line. Take a look at the code below.&lt;/div&gt;&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Pyramid&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;the&amp;nbsp;length&amp;nbsp;of&amp;nbsp;pyramid&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;rows&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------Output------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;rows;&amp;nbsp;i&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i--&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;j&amp;nbsp;&amp;lt;=&amp;nbsp;i;&amp;nbsp;j++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------------------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
If you look at the code above, we have just made a slight change in the&amp;nbsp;declaration of outer loop. &amp;nbsp;This it the outer loop will start from the entered number and end at 1. After every iteration we decrease the value by one.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Output of Program:-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0rLDqWsKDx5xGzljopoFQ4kVU_K_Afi7bb0cNZTEm3-4shSrInd1qd2-WvtRbBlS1k3TiZk8QjLD1QbBe4vT7Nx3lt6rWFlcdlT4KM21qmJv3QI6opMDy2d_A5uawulGLPvG-ClaKVzA/s1600/Reverse+Pyramid.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0rLDqWsKDx5xGzljopoFQ4kVU_K_Afi7bb0cNZTEm3-4shSrInd1qd2-WvtRbBlS1k3TiZk8QjLD1QbBe4vT7Nx3lt6rWFlcdlT4KM21qmJv3QI6opMDy2d_A5uawulGLPvG-ClaKVzA/s1600/Reverse+Pyramid.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Some more examples of different Pyramids:-&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;div style=&quot;text-align: right;&quot;&gt;&lt;b style=&quot;background-color: transparent; text-align: justify;&quot;&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; text-align: justify;&quot;&gt;&lt;b style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;** &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; text-align: justify;&quot;&gt;&lt;b&gt;&lt;b style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*** &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: right;&quot;&gt;&lt;span style=&quot;background-color: transparent; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&lt;b style=&quot;background-color: transparent; color: #333333; font-size: 15px;&quot;&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;**** &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: right;&quot;&gt;&lt;span style=&quot;background-color: transparent; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&lt;b style=&quot;background-color: transparent; color: #333333; font-size: 15px;&quot;&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;***** &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;If you look at this example, it can look a bit confusing, but it is not as much difficult as you might think. Lets take a look below.&lt;br /&gt;
&lt;table align=&quot;center&quot; bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ----*&lt;/span&gt; &lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;background-color: transparent; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ---**&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; --***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -****&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; *****&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;Now its easy to understand the logic for this program. For this program we have to need to an extra for loop in our previous code of pyramid. Here is the code :&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Pyramid&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;the&amp;nbsp;length&amp;nbsp;of&amp;nbsp;pyramid&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;rows&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------Output------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;=&amp;nbsp;rows;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&amp;nbsp;=&amp;nbsp;rows-&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;j&amp;nbsp;&amp;gt;=&amp;nbsp;i;&amp;nbsp;j--&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;k&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;k&amp;nbsp;&amp;lt;=&amp;nbsp;i;&amp;nbsp;k++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;-------------------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Output of Program:-&lt;/u&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQvllbzqeC-Djzo_L-lY03oiVWrBZVRmBJI52rP-gAf0PCCjjPvKYTeEQIOQ65Npp-JFv5bnMRAr2T7k5K8Ht5W2juFmJ_amOXJiRj4YKdlOpL97M-3aMVM7cJfXme_oQS07RnvQ-PUXA/s1600/Pyramid+Java.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQvllbzqeC-Djzo_L-lY03oiVWrBZVRmBJI52rP-gAf0PCCjjPvKYTeEQIOQ65Npp-JFv5bnMRAr2T7k5K8Ht5W2juFmJ_amOXJiRj4YKdlOpL97M-3aMVM7cJfXme_oQS07RnvQ-PUXA/s1600/Pyramid+Java.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;For more pyramid examples go to :&amp;nbsp;&lt;span style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; line-height: 20px;&quot;&gt;&lt;a href=&quot;http://javacodespot.blogspot.com/2012/01/java-programming-pyramids-2.html&quot; target=&quot;_blank&quot;&gt;JAVA Pyramids 2&lt;/a&gt;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/1028582091830425412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2012/01/java-programming-pyramids.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1028582091830425412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1028582091830425412'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2012/01/java-programming-pyramids.html' title='JAVA Programming : Pyramids'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEhhQfxpiz7JkATTMDbsLuPzrAn27NcF8KPhGudZv9ofsqkt8vbxuPN4-VGk5SZ1MvPqlPlK47AM-qBsWAsHtLBtx62OWB08obTFi27bErWUDYx_iU55IW_Y4TyATjOQCWOAvQw5O6oG9Lo/s72-c/JavaPyramid.JPG" height="72" width="72"/><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-2831930147103899391</id><published>2012-01-22T03:24:00.000-08:00</published><updated>2012-01-22T03:30:38.429-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Break, Continue And Return</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA Break, Continue And Return&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Java has three type of branching control keywords: break, continue and return. These keywords are used to change the normal flow of execution of program.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;Break keyword :&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The break keyword is used to stop the&amp;nbsp;execution&amp;nbsp;of the loops. In many situations we need to get out of the loop before the loop execution is complete.&amp;nbsp;Whenever a break keyword is encountered inside a loop the execution gets out of loop and start executing the next line of code after the loop.&amp;nbsp;The break statement is of two types: &lt;i&gt;labeled&lt;/i&gt; and&lt;i&gt; unlabeled&lt;/i&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;u&gt;Unlabeled break statement:&lt;/u&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Unlabeled break statement is used to get out of a single loop. If unlabeled break is used inside the nested loops it will exit only from the loop in which break is used. Lets see the example below:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;UnlabeledBreak&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;while&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i &amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;==&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;i&amp;nbsp;=&amp;nbsp;&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Output of Program:&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuNh8nuCSYULTelCv-NHNuyH_JXFRbJT5vGqbJrHq96pUWLoDilnOefOv6wWbC-XQCBK_Ti3mjD-FCga8ri5FaantnWhEgmZQnzAjw1MUjEUAVhs7l1mIxV-rlBJPZkJxl10ag-5CMukc/s1600/UnlabeledBreak.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;172&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuNh8nuCSYULTelCv-NHNuyH_JXFRbJT5vGqbJrHq96pUWLoDilnOefOv6wWbC-XQCBK_Ti3mjD-FCga8ri5FaantnWhEgmZQnzAjw1MUjEUAVhs7l1mIxV-rlBJPZkJxl10ag-5CMukc/s640/UnlabeledBreak.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;i&gt;&lt;u&gt;Labeled Break Statement:&lt;/u&gt;&amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Labeled breaks statement is used when we need to break the nested loops. Lets understand the difference between Labeled and Unlabeled break statement with an example.&lt;br /&gt;
In this example we need to&amp;nbsp;traverse a 2D array and print the elements of array until a particular element is found. To do this we have to use nested loops. Now to break and get out of the nested loops we need to use labeled break.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055; text-align: justify;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; text-align: justify;&quot;&gt;LabeledBreak&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; text-align: justify;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[][]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{{&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;OuterLoop:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;a.length;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.length;&amp;nbsp;j++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;][&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;][&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;OuterLoop;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Program&amp;nbsp;Ends&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Output of Program:-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLz_zNIR5Ix76xtVHTjp5BjBi0Ghp-3gKEdSAoUFMYL7GFzxunkm37yWGtLxeN-RvfAGt9Mv5PAx-JlQz9CnDCmhsnmOh33hYHX9FH24yWYC0Ndaae5092dG-XVBbKwZzbVYZVMKNmdfA/s1600/LabeledBreak.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLz_zNIR5Ix76xtVHTjp5BjBi0Ghp-3gKEdSAoUFMYL7GFzxunkm37yWGtLxeN-RvfAGt9Mv5PAx-JlQz9CnDCmhsnmOh33hYHX9FH24yWYC0Ndaae5092dG-XVBbKwZzbVYZVMKNmdfA/s640/LabeledBreak.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;
&lt;/u&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Continue Keyword:-&lt;/u&gt;&amp;nbsp;Continue statement statement is used to skip a single&amp;nbsp;iteration of a loop. Whenever&amp;nbsp;a continue keyword is encountered&amp;nbsp;inside a loop, the current iteration of loop ends&amp;nbsp;just like a normal end of any iteration&amp;nbsp;without executing the statement written after the continue statement inside the loop. Just like break statement continue statement is also of two types:&amp;nbsp;&lt;i&gt;labeled&lt;/i&gt;&amp;nbsp;and&lt;i&gt;&amp;nbsp;unlabeled&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;u style=&quot;font-style: italic;&quot;&gt;Unlabeled Continue Statement:&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055; text-align: justify;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; text-align: justify;&quot;&gt;UnlabeledContinue&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; text-align: justify;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Numbers&amp;nbsp;divisible&amp;nbsp;by&amp;nbsp;3&amp;nbsp;or&amp;nbsp;5&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;a.length;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&amp;nbsp;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;continue&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Output of Program:&lt;/u&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguk56j0Yf0HifRMR8V2OnufMnfgKa7Zuf9Id5tVvW2woVzL3XzLZp2JA2gsC6RVYiNUmNWZ8bh8tNWTXSafzt1x12KuTCvjeo3xoWXIC4ViFgFxyeAAKwxp_D2hJbdFEWU9_TdiadsIIo/s1600/UnlabeledContinue.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;211&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguk56j0Yf0HifRMR8V2OnufMnfgKa7Zuf9Id5tVvW2woVzL3XzLZp2JA2gsC6RVYiNUmNWZ8bh8tNWTXSafzt1x12KuTCvjeo3xoWXIC4ViFgFxyeAAKwxp_D2hJbdFEWU9_TdiadsIIo/s640/UnlabeledContinue.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;i style=&quot;text-decoration: underline;&quot;&gt;Labeled Continue Statement:&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055; text-align: justify;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; text-align: justify;&quot;&gt;ContinueLabel&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; text-align: justify;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[])&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;outer:&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;j++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;j&amp;nbsp;&amp;gt;&amp;nbsp;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;continue&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;outer;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.print&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Output of Program:-&lt;/u&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEOhX9XhfrsWOtGINTTInBvFFRFf1E7L0xyYI2-To_l2zx4a_Ftw77l0F6fGaQ4wNeYd8Zo6-ksLSMBjrslz9iTZ2Xm_u3ce9dyd_3dBVqB_Ys3K9oLLKpr2jOhGXJyPSCfIsFTEc_pwM/s1600/Labeled+Continue.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEOhX9XhfrsWOtGINTTInBvFFRFf1E7L0xyYI2-To_l2zx4a_Ftw77l0F6fGaQ4wNeYd8Zo6-ksLSMBjrslz9iTZ2Xm_u3ce9dyd_3dBVqB_Ys3K9oLLKpr2jOhGXJyPSCfIsFTEc_pwM/s640/Labeled+Continue.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Return Keyword:-&lt;/u&gt;&amp;nbsp;Return statement is a bit different form break and continue as break and continue changes the normal control flow of loops but return statement works on the control flow of the &lt;a href=&quot;http://javacodespot.blogspot.com/2011/03/java-programming-methods.html&quot; target=&quot;_blank&quot;&gt;method&lt;/a&gt;. Return statement stops execution of the method and transfer the control back to the caller of the method. The return statement can be used in two ways, &amp;nbsp;return statement that returns a value and another that does not return a value. Return statement must return the same type of value as defined in the declaration of &lt;a href=&quot;http://javacodespot.blogspot.com/2011/03/java-programming-methods.html&quot; target=&quot;_blank&quot;&gt;method&lt;/a&gt;. If the method is defined as void than return statement will not return any value.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #7f0055; text-align: justify;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; text-align: justify;&quot;&gt;ReturnStatement&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; text-align: justify;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ReturnStatement&amp;nbsp;rs&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ReturnStatement&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Largest&amp;nbsp;Number&amp;nbsp;is:&amp;nbsp;&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;rs.largestNumber&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;largestNumber&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num1,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num2,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;largest&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num1&amp;nbsp;&amp;gt;&amp;nbsp;num2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num1&amp;nbsp;&amp;gt;&amp;nbsp;num3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;largest&amp;nbsp;=&amp;nbsp;num1;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num2&amp;nbsp;&amp;gt;&amp;nbsp;num3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num2&amp;nbsp;&amp;gt;&amp;nbsp;num1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;largest&amp;nbsp;=&amp;nbsp;num2;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: #7f0055;&quot;&gt;else&lt;/b&gt;{&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;largest&amp;nbsp;=&amp;nbsp;num3;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;largest;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
The use of return statement will be more clear in upcoming tutorials and we will be using it more and more now.&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/2831930147103899391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2012/01/break-continue-return.html#comment-form' title='190 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2831930147103899391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2831930147103899391'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2012/01/break-continue-return.html' title='JAVA Programming : Break, Continue And Return'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEiuNh8nuCSYULTelCv-NHNuyH_JXFRbJT5vGqbJrHq96pUWLoDilnOefOv6wWbC-XQCBK_Ti3mjD-FCga8ri5FaantnWhEgmZQnzAjw1MUjEUAVhs7l1mIxV-rlBJPZkJxl10ag-5CMukc/s72-c/UnlabeledBreak.JPG" height="72" width="72"/><thr:total>190</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-6458498195973792883</id><published>2012-01-10T11:12:00.000-08:00</published><updated>2012-01-10T11:16:06.389-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : For Each Loop</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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA For Each Loop&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;For each loop or Enhance For loop is a extended version of basic for loop which was introduced in Java 5. For each loop is&amp;nbsp;designed&amp;nbsp;to make iteration over arrays and collections much easier. For each loop also makes the code more readable. In this post we will learn about basics of For each loop using &amp;nbsp;Arrays. We will&amp;nbsp;discuses more about For Each loop when we learn about Collections and&amp;nbsp;Iterator.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Syntax of For Each Loop:-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;b style=&quot;color: #7f0055;&quot;&gt; &amp;nbsp; &amp;nbsp;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;type&amp;nbsp;var&amp;nbsp;:&amp;nbsp;arr&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black;&quot;&gt;)&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//body-of-loop &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Example of For Each Loop:-&lt;/u&gt;&amp;nbsp;This is a very simple example in which we will traverse an array using For Each loop and print all the elements of the array.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ForLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;char&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;charArr&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;a&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;b&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;c&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;d&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;e&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;char&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;c&amp;nbsp;:&amp;nbsp;charArr&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
To understand the difference between Basic For loop and For Each Loop, here is the same program using For Loop.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ForLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;char&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;charArr&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;a&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;b&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;c&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;d&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;e&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;charArr.length;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;charArr&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Advantages of For Each Loop:-&lt;/u&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Less number of variables are used&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Less chance of errors&lt;/li&gt;
&lt;li&gt;Improve Readability&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Limitation of For Each Loop:-&lt;/u&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Cannot traverse multiple collection at once.&lt;/li&gt;
&lt;li&gt;Iterates only forward by single steps.&lt;br /&gt;
&lt;/li&gt;&lt;/ul&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/6458498195973792883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2012/01/for-each-loop.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/6458498195973792883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/6458498195973792883'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2012/01/for-each-loop.html' title='JAVA Programming : For Each Loop'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-2863201386723634706</id><published>2011-12-25T09:16:00.000-08:00</published><updated>2012-01-10T11:20:04.659-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : For Loop</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA For Loop&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&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;For loop in java is one of the most common type of loop. There are two types of for loop:&lt;/div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Basic For loop&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;For Each loop &amp;nbsp;(Introduced in Java 5)&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u&gt;&lt;b&gt;Basic For loop:&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;For loop declaration has there parts :&lt;i&gt;&amp;nbsp;initialization, termination condition, iteration&amp;nbsp;expression. &lt;/i&gt;These parts are&amp;nbsp;separated by&amp;nbsp;semicolons.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;Syntax of for loop:-&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;for&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;initialization;&amp;nbsp;condition;&amp;nbsp;iteration&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statements&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Initialization part:&lt;/b&gt; The initialization part of for loop is executed only for the first when the loop begins. It lets you declare and&amp;nbsp;initialize&amp;nbsp;one or more variables of the same types. One thing to note when the declaring a variable in for loop is the scope of variable. If the variable is declared in the for loop the variable&#39;s scope is limited to the for loop.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Condition part:&lt;/b&gt;&amp;nbsp;The condition part must be an&amp;nbsp;Boolean&amp;nbsp;expression. In condition part there cannot be multiple test condition but we can use logical operators to make a logical&amp;nbsp;expression&amp;nbsp;that evaluates into a&amp;nbsp;Boolean result.&amp;nbsp;The body of the for loop is executed only if the condition is true else the loop is terminated.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Iteration part:&lt;/b&gt;&amp;nbsp;After every iteration of &amp;nbsp;for loop&#39;s body,&amp;nbsp;the iteration part is executed. This is the part where you can set the change&amp;nbsp;in loop control variable.&amp;nbsp;The given example will give a better understanding of working of for loop.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Example of for loop:-&lt;/u&gt;&amp;nbsp;This is a very simple example of for loop which will take an integer input form user and print the table of that number.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;color: #7f0055; font-family: monospace;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ForLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;a&amp;nbsp;number&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;userInput=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;result=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Table&amp;nbsp;of&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+userInput&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;--------------&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;num &amp;lt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;num++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;result=userInput*num;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;userInput+&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;*&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+num+&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;=&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+result&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In this program, a &lt;i&gt;&lt;a href=&quot;http://javacodespot.blogspot.com/2011/04/java-programming-using-scanner-for-user.html&quot; target=&quot;_blank&quot;&gt;Scanner class&lt;/a&gt;&lt;/i&gt; is used to take input from user. Next, is a for loop which is declare to run10 times.&amp;nbsp;This for loop starts with initialization int&amp;nbsp;&lt;i&gt;num&lt;/i&gt;=1, and executes the body part&amp;nbsp; till the condition &lt;i&gt;num&lt;/i&gt;&amp;lt;=10 becomes false, after executing the body of for loop for each and every time &lt;i&gt;num &lt;/i&gt;value will be incremented by 1.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;Output of Program:-&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;
&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLAjGWcArO_YUIxSWTixJ3CLO8YfA_zsowkkA_Mg0CZuDZC_82T8XGLWGIzoW8tdtFS798ivu3xuh34DlD_TSzcj6t63xHhAjQQm5H98zVew8yzjbzEe_jTF-Hs3NCPdLk1OVqN1FulA0/s1600/ForLoop.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;307&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLAjGWcArO_YUIxSWTixJ3CLO8YfA_zsowkkA_Mg0CZuDZC_82T8XGLWGIzoW8tdtFS798ivu3xuh34DlD_TSzcj6t63xHhAjQQm5H98zVew8yzjbzEe_jTF-Hs3NCPdLk1OVqN1FulA0/s640/ForLoop.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Different ways of using For Loop:-&lt;/u&gt;&lt;/b&gt; For Loop can be used in different ways and sometimes it can be very complex. We will discuses this in the examples below. In For loop there is one thing to notice that all three declaration part of for loop can be left blank.&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #93c47d;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//infinite loop&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;The code above is will work as an infinite loop or endless loop and it will work same as &lt;i&gt;while(true)&lt;/i&gt;&amp;nbsp;loop.&lt;br /&gt;
&lt;br /&gt;
As we now know that all three part of For loop are optional and can be left blank but it is very&amp;nbsp;interesting&amp;nbsp;to know that what kind of code you can write in these parts.&amp;nbsp;The condition part is the only part of for loop&amp;nbsp;declaration&amp;nbsp;for which there is a rule defined that it must be an&amp;nbsp;Boolean&amp;nbsp;expression. In the remaining two, Initialization&amp;nbsp;and Iteration part we can actually write any peace of code.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ForLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Initializtion&amp;nbsp;Part&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Iteration&amp;nbsp;Part&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Body&amp;nbsp;part&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Output of Program:-&lt;/u&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMzhHekuVFjUmbjtBp8-qMXel7pOAl0VaMmAxQfvj7KieynxID4JBJqj3HIGgLQcNWihbmQNZCCz5jU4LmnyTvNANgh_mxvZ18aRjO1ywLBohFut0m0QV1p3RCPL8mQmepIbYCbocYtEQ/s1600/ForLoop1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMzhHekuVFjUmbjtBp8-qMXel7pOAl0VaMmAxQfvj7KieynxID4JBJqj3HIGgLQcNWihbmQNZCCz5jU4LmnyTvNANgh_mxvZ18aRjO1ywLBohFut0m0QV1p3RCPL8mQmepIbYCbocYtEQ/s640/ForLoop1.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Use of comma and logical operators in For loop:-&lt;/u&gt;&lt;/b&gt; In For loop we can use multiple statements in initialization and iteration parts using comma. In initialization part we can define multiple variables by separating the variables with comma but the variables must be of same type.&lt;br /&gt;
As we know, condition part of the for loop must be an boolean&amp;nbsp;expression&amp;nbsp;therefor use of comma is not allowed but we can use logical operators to make a valid boolean&amp;nbsp; expression.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ForLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;b=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;c=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;a&amp;lt;b&amp;nbsp;||&amp;nbsp;a&amp;lt;c&amp;nbsp;;&amp;nbsp;a++,b--,c--&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;=&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+a+&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;b&amp;nbsp;=&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+b+&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;c&amp;nbsp;=&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+c&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Output of the program:-&lt;/u&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV1835R4-T7Dnc9SQ5mc3GXxcUXIy2rdiEUfs6_vbRwW37fMOWJD2dXi7GYTZRMelQHgARnfAYsZvk-u9tNKdMxV6__EtqSHqqhQHbBS801g5bYTIXPi7CjR-fVBbjqT-wSFziDKamRKU/s1600/ForLoop.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV1835R4-T7Dnc9SQ5mc3GXxcUXIy2rdiEUfs6_vbRwW37fMOWJD2dXi7GYTZRMelQHgARnfAYsZvk-u9tNKdMxV6__EtqSHqqhQHbBS801g5bYTIXPi7CjR-fVBbjqT-wSFziDKamRKU/s640/ForLoop.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In the next post we will learn about &lt;a href=&quot;http://javacodespot.blogspot.com/2012/01/for-each-loop.html&quot; target=&quot;_blank&quot;&gt;For each loop or Enhanced For Loop.&lt;/a&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/2863201386723634706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/12/for-loop.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2863201386723634706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2863201386723634706'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/12/for-loop.html' title='JAVA Programming : For Loop'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEhLAjGWcArO_YUIxSWTixJ3CLO8YfA_zsowkkA_Mg0CZuDZC_82T8XGLWGIzoW8tdtFS798ivu3xuh34DlD_TSzcj6t63xHhAjQQm5H98zVew8yzjbzEe_jTF-Hs3NCPdLk1OVqN1FulA0/s72-c/ForLoop.JPG" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-3887075870043568763</id><published>2011-11-23T10:56:00.000-08:00</published><updated>2011-11-23T10:58:12.313-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Do While Loop</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA Do While Loop&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Do Loop is very similar to the while loop. The only difference between while and do while loop is that the&amp;nbsp;while loop first checks the condition and executes the body of while loop only if the conditions results&amp;nbsp;as&amp;nbsp;true but in while loop the condition is evaluated after the loops body is executed once, so even if the condition is false at the first time the body of loop will be executed&amp;nbsp;at least&amp;nbsp;once.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;&amp;nbsp; do&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;while&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;condition&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Example of Do While loop:-&lt;/u&gt;&amp;nbsp;The examples below will explain the working of do while loop.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In the examples below the while loop and do while will work&amp;nbsp;exactly same i.e. will give the same output.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;color: #7f0055; font-family: monospace;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;DoWhileLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;do&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;enter&amp;nbsp;into&amp;nbsp;loop&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;while&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;color: #7f0055; font-family: monospace;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;DoWhileLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;while&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i &amp;lt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;enter&amp;nbsp;into&amp;nbsp;loop&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In the examples below the while loop and do while will not give the same output.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;color: #7f0055; font-family: monospace;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;DoWhileLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;do&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;enter&amp;nbsp;into&amp;nbsp;loop&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;while&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;color: #7f0055; font-family: monospace;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;DoWhileLoop&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;while&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i &amp;lt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;enter&amp;nbsp;into&amp;nbsp;loop&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;div&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In these examples the condition will be false at the first time so the body of while loop will never get processed but the body of do while will be processed once.&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/3887075870043568763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/11/do-while-loop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/3887075870043568763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/3887075870043568763'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/11/do-while-loop.html' title='JAVA Programming : Do While Loop'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-3589929297001994161</id><published>2011-11-23T07:19:00.000-08:00</published><updated>2011-11-23T08:02:40.827-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : While Loop</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA While Loop&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Loops in java are the control flow statements that are used to repeat a block of code multiple times according to a given condition. &amp;nbsp;There are three types of loops: For , Do , While. The while loop is very simple but very effective when we have to execute a block of code until a particular&amp;nbsp;expression(condition) is true. The condition will evaluate into a boolean result.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;Syntax of while loop:-&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;
&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; while&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;condition&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statements &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3f7f5f;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b style=&quot;text-decoration: underline;&quot;&gt;Example of while loop:-&lt;/b&gt;&amp;nbsp;To understand the&amp;nbsp;functionality of while loop lets see the example. While loop first checks the given condition, if the condition results into true then the statement&amp;nbsp;written inside the while loop block will be executed and then the condition is checked again. This process goes until the given condition is false.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;span style=&quot;color: #7f0055; font-family: monospace;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: monospace;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;While&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;any&amp;nbsp;number&amp;nbsp;to&amp;nbsp;print&amp;nbsp;table&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;while&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;num+&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;*&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+i+&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;=&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+num*i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b style=&quot;text-decoration: underline;&quot;&gt;Output of Program:-&lt;/b&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1AbuNOZhKuBxCkq_4YFImmzQA4CbaY-l0I03AlMCKoaJ_uuF_l6gimoEPBNKn8hjZUB6irISpSHYpzyQT9aq7fc-cz3x3a5VxEEiTZnoiAnEtrZIch-YhQJLUWWdfKpxITYRAgkIT1NM/s1600/While+Loop.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1AbuNOZhKuBxCkq_4YFImmzQA4CbaY-l0I03AlMCKoaJ_uuF_l6gimoEPBNKn8hjZUB6irISpSHYpzyQT9aq7fc-cz3x3a5VxEEiTZnoiAnEtrZIch-YhQJLUWWdfKpxITYRAgkIT1NM/s1600/While+Loop.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/3589929297001994161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/11/while-loop-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/3589929297001994161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/3589929297001994161'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/11/while-loop-java.html' title='JAVA Programming : While Loop'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEi1AbuNOZhKuBxCkq_4YFImmzQA4CbaY-l0I03AlMCKoaJ_uuF_l6gimoEPBNKn8hjZUB6irISpSHYpzyQT9aq7fc-cz3x3a5VxEEiTZnoiAnEtrZIch-YhQJLUWWdfKpxITYRAgkIT1NM/s72-c/While+Loop.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-7103387784068567339</id><published>2011-07-19T13:35:00.000-07:00</published><updated>2011-07-20T10:14:08.545-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Switch Statement</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA Switch Statement&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Switch Statement is also a control flow statement like If statement. But Switch statement is a bit different from If statement, because an If statement can only choose one course of action form multiple choices but switch statement can have multiple outcomes. We will explain it below. A switch statement works only for convertible int values (like byte, int, short, char) and enum constants. &lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;Syntax of Switch Statement:&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;&amp;nbsp;switch&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;expression&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;constantOne:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statement &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;constantTwo:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;constantThree:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;default&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Now lets see the functionality of Switch statement: In a switch statement the flow of execution starts from top to down i.e. the first case will be evaluated and the second case and so on and wherever it finds the matching case it will execute the associated code block and the remaining code block till the end of switch. Let’s understand with an example:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;SwitchStatement&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;switch&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;one&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;two&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;three&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;four&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The output of this program is :&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;b&gt;&lt;i&gt;two&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;three&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;four&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Here we can see that after finding the matching case, the associated code block and all the code blocks after that will get executed till the end of switch statement. This kind of situation is called &lt;i&gt;fall through. &lt;/i&gt;To overcome this problem we can use break statement.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Break:&lt;/u&gt;&amp;nbsp;Whenever the program finds a break statement, the execution of program jumps out of switch. Break statement is also used in loops like for and while. We discusses about it later.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;SwitchStatement&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;switch&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;one&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;two&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;three&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;four&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;This is same example as above but with a slight change. We have used the break statement in all cases. So, the output of this program will be:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;b&gt;&lt;i&gt;two&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;This is because when it executes the case 2 block it will encounters a break statement and the execution of program will move out of switch immediately without executing remaining cases. This way it avoids the &lt;i&gt;fall through &lt;/i&gt;situation.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Default:&lt;/u&gt;&amp;nbsp;Default works same as Else in If-Else statement. In switch statement if there is no matching case the default case will get executed. Here is an example:&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.util.*;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;SwitchStatement&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;option=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;week=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scn&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Enter&amp;nbsp;a&amp;nbsp;Weekday&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;option=scn.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;switch&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;option&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Sunday&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Monday&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Tuesday&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Wednesday&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Thursday&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Friday&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;case&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Saturday&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;default&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Wrong&amp;nbsp;option&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;break&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Output of Program:&lt;/u&gt;&amp;nbsp;When there is a matching switch case.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5yDEj65kRpD-2uIU5rqMhsFmLVPrGOqqT2s0PoOJQgB90K_z_2Aw-fu9b9Lj9e_PfkeQsMDqxay1AY6W1SXdLdY-9P10Dpft7KRuJFTn_n9cD1FUeJJvIp1Oe75iM5D_3414KGUXDDK8/s1600/Switch+Statement+java.bmp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5yDEj65kRpD-2uIU5rqMhsFmLVPrGOqqT2s0PoOJQgB90K_z_2Aw-fu9b9Lj9e_PfkeQsMDqxay1AY6W1SXdLdY-9P10Dpft7KRuJFTn_n9cD1FUeJJvIp1Oe75iM5D_3414KGUXDDK8/s1600/Switch+Statement+java.bmp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;When there is no matching case the default code block will execute.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbUPlLcjhbWmD9s5sWzWesmi0E1Y7g9ZgKFwYbmWbayQOm-65gp8bPBu-uH64_9Kfzx1zUWKjKItXpfhqrJXSUp4kB_hniGF89X5yAvGFwLXlsINqjDnqP_cfqQS_Vu1JWSMvaP3yFuk0/s1600/Switch+Statement+Default.bmp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbUPlLcjhbWmD9s5sWzWesmi0E1Y7g9ZgKFwYbmWbayQOm-65gp8bPBu-uH64_9Kfzx1zUWKjKItXpfhqrJXSUp4kB_hniGF89X5yAvGFwLXlsINqjDnqP_cfqQS_Vu1JWSMvaP3yFuk0/s1600/Switch+Statement+Default.bmp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/7103387784068567339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/07/switch-statement-java.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7103387784068567339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7103387784068567339'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/07/switch-statement-java.html' title='JAVA Programming : Switch Statement'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEh5yDEj65kRpD-2uIU5rqMhsFmLVPrGOqqT2s0PoOJQgB90K_z_2Aw-fu9b9Lj9e_PfkeQsMDqxay1AY6W1SXdLdY-9P10Dpft7KRuJFTn_n9cD1FUeJJvIp1Oe75iM5D_3414KGUXDDK8/s72-c/Switch+Statement+java.bmp" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-2770045413014374642</id><published>2011-06-20T11:35:00.000-07:00</published><updated>2011-07-14T07:20:48.781-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : If Statement</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA If Statement&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;If statement&lt;/b&gt; may be defined as a decision making statement, a control flow statement or a selection statement. In a simple program the execution of code starts form first line and ends at the last line but what if we want to execute a block of code only under a certain circumstances. The if statement is the simplest decision making statement. An If statement evaluates a Boolean expression (true or false) and determine whether to run a particular set of statement or not. The syntax of an if statement is:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;booleanExpression&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{ &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statement&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Example of If Statement:&lt;/u&gt;&amp;nbsp;Using If statement to find out whether a number is divisible of 5 or not.&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;IfStatement&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;x=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;x%&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;x&amp;nbsp;is&amp;nbsp;divisble&amp;nbsp;by&amp;nbsp;5&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;If-Else Statement:-&lt;/u&gt;&amp;nbsp;An &lt;i&gt;If&lt;/i&gt; statement runs a block of code if the testing condition is true. By using &lt;i&gt;If-else&lt;/i&gt; statement we can give another another block of code that will run when the &lt;i&gt;If&lt;/i&gt; condition is not true. In other words in &lt;i&gt;If-Else&lt;/i&gt; statement code in &lt;i&gt;If&lt;/i&gt; block will run when condition is true and code in &lt;i&gt;Else&lt;/i&gt; block will run when condition is false. Below is the syntax of &lt;i&gt;If-Else&lt;/i&gt; statement.&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;booleanExperssion&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){ &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//set&amp;nbsp;of&amp;nbsp;statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Example of &lt;i&gt;If-Else &lt;/i&gt;Statement:&lt;/u&gt;&amp;nbsp;In this example we will find weather a number is odd or even using If-Else Statement. As we know if a number is divisible by 2 then it is an even number else it is an odd number.&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;IfElseStatement&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;x=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;x%&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;x&amp;nbsp;is&amp;nbsp;an&amp;nbsp;even&amp;nbsp;number&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;x&amp;nbsp;is&amp;nbsp;an&amp;nbsp;odd&amp;nbsp;number&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;If Else If Statement:&lt;/u&gt;&lt;/b&gt; If-Else-If Statement is used when we have to choose form multiple course of action or we can say If-Else-If Statement is used when we have to check multiple conditions and there is different course of action for every condition. Let’s understand it with an example where we have to set student’s grade on the basis of marks.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;IfElseIf&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;marks=&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000; font-family: monospace;&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;char&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;90&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;80&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;B&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;C&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;E&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In &lt;i&gt;If-Else-If&lt;/i&gt; statements once a condition is found true that particular block of statement are executed and rest of the condition will not be checked. For example when first&lt;i&gt; If&lt;/i&gt; condition is found true, it will not check the&amp;nbsp;rest of the &lt;i&gt;Else If&lt;/i&gt; or else statements otherwise it will check the second &lt;i&gt;Else If&lt;/i&gt; and so on.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In this example, marks are 85 therefore it satisfies more than one given conditions which is greater than equal to 60, greater than equal to 70 and grater than equal to 80. But when the first else if which is greater that equal to 80 found true it will not check the remaining conditions and the grade will be set to B which is the correct grade. But here you can notice a&amp;nbsp;wrongly&amp;nbsp;formatted code can lead to an error. Lets take a look at the code below:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;IfElseIf&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;marks=&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000; font-family: monospace;&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;char&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;= &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;= &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;C&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;= &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;B&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000; font-family: monospace;&quot;&gt;90&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;E&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In this program as the first if condition is true the grade will be set to D and rest of conditions will be ignored. But the correct grade should be B as the marks scored are more than 80. So now we can see if the program is not correctly formatted it can lead to errors. This problem can be solved using multiple condition in one &lt;i&gt;If&lt;/i&gt; block using &lt;a href=&quot;http://javacodespot.blogspot.com/2011/04/java-programming-operators.html&quot;&gt;logical operators&lt;/a&gt; like || and &amp;amp;&amp;amp;.&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;IfElseIf&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;85&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;char&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;60&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&amp;nbsp;marks&amp;nbsp;&amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;70&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&amp;nbsp;marks&amp;nbsp;&amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;80&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){ &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;C&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;80&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&amp;nbsp;marks&amp;nbsp;&amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;90&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;B&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;marks&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;90&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;grade&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;E&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Here by giving multiple conditions using logical operators we can make sure that the code will result in correct output even if the code is not correctly formatted.&amp;nbsp;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/2770045413014374642/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/06/if-statement-java.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2770045413014374642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2770045413014374642'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/06/if-statement-java.html' title='JAVA Programming : If Statement'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-7570707742003007890</id><published>2011-04-22T05:37:00.000-07:00</published><updated>2011-07-14T02:34:32.474-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Operators</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA Operators&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;A Operator in Java is a Symbol that manipulates one or more primitive&amp;nbsp;data types (arguments) to produce a result. Operators are very important part of Java programming. Below is the list of Operators available in Java.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableLightShadingAccent6&quot; style=&quot;border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 12.05pt; mso-yfti-firstrow: yes; mso-yfti-irow: -1;&quot;&gt;    &lt;td colspan=&quot;8&quot; style=&quot;border-bottom: solid #F79646 1.0pt; border-left: none; border-right: none; border-top: solid #F79646 1.0pt; height: 12.05pt; mso-border-bottom-themecolor: accent6; mso-border-top-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 495.65pt;&quot; valign=&quot;top&quot; width=&quot;661&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 1;&quot;&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 14pt;&quot;&gt;OPERATORS&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 23.5pt; mso-yfti-irow: 0;&quot;&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 23.5pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;Assignment Operators&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td colspan=&quot;7&quot; style=&quot;background: #FDE4D0; border: none; height: 23.5pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 495.65pt;&quot; valign=&quot;top&quot; width=&quot;661&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 11.45pt; mso-yfti-irow: 1;&quot;&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 22.95pt; mso-yfti-irow: 2;&quot;&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;Arithmetic Operators&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;-&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;+&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;%&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;++&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 11.45pt; mso-yfti-irow: 3;&quot;&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 22.95pt; mso-yfti-irow: 4;&quot;&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;Relational Operators&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;lt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;gt;=&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;lt;=&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;==&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 11.45pt; mso-yfti-irow: 5;&quot;&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 22.95pt; mso-yfti-irow: 6;&quot;&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;Logical Operators&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;amp;&amp;amp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;||&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 11.45pt; mso-yfti-irow: 7;&quot;&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 22.95pt; mso-yfti-irow: 8;&quot;&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;Bit wise Operator&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;amp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;|&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;^&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;gt;&amp;gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 22.95pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 11.45pt; mso-yfti-irow: 9;&quot;&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 36.15pt; mso-yfti-irow: 10;&quot;&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 36.15pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;Compound Assignment Operators&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 36.15pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;+=&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 36.15pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;-=&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 36.15pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;*=&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 36.15pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;/=&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 36.15pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;%=&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;background: #FDE4D0; border: none; height: 36.15pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border: none; height: 36.15pt; mso-background-themecolor: accent6; mso-background-themetint: 63; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 11.45pt; mso-yfti-irow: 11;&quot;&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border: none; height: 11.45pt; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 37.3pt; mso-yfti-irow: 12; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;background: #FDE4D0; border-bottom: solid #F79646 1.0pt; border: none; height: 37.3pt; mso-background-themecolor: accent6; mso-background-themetint: 63; mso-border-bottom-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 79.0pt;&quot; valign=&quot;top&quot; width=&quot;105&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 12pt;&quot;&gt;Conditional Operator&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border-bottom: solid #F79646 1.0pt; border: none; height: 37.3pt; mso-background-themecolor: accent6; mso-background-themetint: 63; mso-border-bottom-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;?:&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border-bottom: solid #F79646 1.0pt; border: none; height: 37.3pt; mso-background-themecolor: accent6; mso-background-themetint: 63; mso-border-bottom-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border-bottom: solid #F79646 1.0pt; border: none; height: 37.3pt; mso-background-themecolor: accent6; mso-background-themetint: 63; mso-border-bottom-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border-bottom: solid #F79646 1.0pt; border: none; height: 37.3pt; mso-background-themecolor: accent6; mso-background-themetint: 63; mso-border-bottom-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border-bottom: solid #F79646 1.0pt; border: none; height: 37.3pt; mso-background-themecolor: accent6; mso-background-themetint: 63; mso-border-bottom-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border-bottom: solid #F79646 1.0pt; border: none; height: 37.3pt; mso-background-themecolor: accent6; mso-background-themetint: 63; mso-border-bottom-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 70.8pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #FDE4D0; border-bottom: solid #F79646 1.0pt; border: none; height: 37.3pt; mso-background-themecolor: accent6; mso-background-themetint: 63; mso-border-bottom-themecolor: accent6; padding: 0in 5.4pt 0in 5.4pt; width: 70.85pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 64;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Assignment Operator:&lt;/u&gt;&amp;nbsp;It is the most common and simple operator that is used to assign value on its right to the operand on its left.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Arithmetic Operators:&lt;/u&gt;&amp;nbsp;As the name suggest these are the operators that are used for performing arithmetic operations. Java provide seven arithmetic operators add,&amp;nbsp;subtract, multiply, divide, mode (returns remainder),&amp;nbsp;unary increment&amp;nbsp;and unary decrement.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Bit Wise Operators:&lt;/u&gt;&amp;nbsp;Bit operator in Java are use to&amp;nbsp;manipulate variables at bit level. It is not recommended to use bit wise&amp;nbsp;operatically&amp;nbsp;in normal application programming because in makes code hard to understand. So, we are not going to discusses bit wise operators in details. In code below we shown how to use these operators.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;u&gt;Compound Operators:-&lt;/u&gt;&amp;nbsp;&lt;/b&gt;Compound operators provide a short way or syntax to write Arithmetic and Bitwise operators. There are&amp;nbsp;eleven compound operators in Java.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Below is the Java Code that shows how to use Assignment, Arithmetic, Bit wise and Compound Operator in a program. This Class&amp;nbsp;doesn&#39;t actually do anything&amp;nbsp;&amp;nbsp;in terms of producing result, but it shows you the syntax to use these operators.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Operators&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;arg&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[])&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;vv&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Assignment&amp;nbsp;Operator&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;vv&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;a&amp;nbsp;has&amp;nbsp;value&amp;nbsp;1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;b&amp;nbsp;has&amp;nbsp;value&amp;nbsp;2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;c&amp;nbsp;=&amp;nbsp;a;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;c&amp;nbsp;gets&amp;nbsp;the&amp;nbsp;value&amp;nbsp;of&amp;nbsp;a&amp;nbsp;i.e&amp;nbsp;1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3f7f5f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Arithmetic&amp;nbsp;Operators&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;b&amp;nbsp;+&amp;nbsp;c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Addition&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;b&amp;nbsp;-&amp;nbsp;c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//subtraction&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;b&amp;nbsp;*&amp;nbsp;c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Multiply&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;b&amp;nbsp;/&amp;nbsp;c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Division&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;b&amp;nbsp;%&amp;nbsp;c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Mode&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3f7f5f;&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;div style=&quot;color: black; font-family: &#39;Times New Roman&#39;; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3f7f5f;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a++;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Increment&amp;nbsp;a&amp;nbsp;by 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a--;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Decrement&amp;nbsp;a&amp;nbsp;by&amp;nbsp;1&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3f7f5f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Bit&amp;nbsp;Wise&amp;nbsp;Operators&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;a&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Left&amp;nbsp;Shift&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;a&amp;nbsp;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Right&amp;nbsp;Shift&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;a&amp;nbsp;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//Unsigned&amp;nbsp;Right&amp;nbsp;Shift&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;b&amp;nbsp;&amp;amp;&amp;nbsp;c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//AND&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;b&amp;nbsp;|&amp;nbsp;c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//OR&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;b&amp;nbsp;^&amp;nbsp;c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//XOR&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;a&amp;nbsp;+&amp;nbsp;b;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//this&amp;nbsp;is&amp;nbsp;normal&amp;nbsp;+&amp;nbsp;operation&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;+=&amp;nbsp;b;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//this&amp;nbsp;is&amp;nbsp;compound&amp;nbsp;operation&amp;nbsp;of&amp;nbsp;above&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//compound&amp;nbsp;Operators&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;-=&amp;nbsp;b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;*=&amp;nbsp;b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;/=&amp;nbsp;b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;%=&amp;nbsp;b;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;gt;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;lt;&amp;lt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;gt;&amp;gt;&amp;gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;amp;=&amp;nbsp;b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;|=&amp;nbsp;b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;^=&amp;nbsp;b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;b&gt;&lt;u&gt;Relational Operator:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Relational Operator in Java are binary operators i.e. they are used to compare two operands. There are six relational operators as shown above. Relational operator in java compare to numaric objects and results in a boolean value.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Relational&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;b&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;&amp;gt;&amp;nbsp;b results in : &quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;gt;&amp;nbsp;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;&amp;lt;&amp;nbsp;b results in :&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;lt;&amp;nbsp;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;&amp;gt;=&amp;nbsp;b&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #2a00ff; font-family: monospace;&quot;&gt;results in :&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;gt;=&amp;nbsp;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;&amp;lt;=&amp;nbsp;b&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #2a00ff; font-family: monospace;&quot;&gt;results in :&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;lt;=&amp;nbsp;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;==&amp;nbsp;b&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #2a00ff; font-family: monospace;&quot;&gt;results in :&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;==&amp;nbsp;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;!=&amp;nbsp;b&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #2a00ff; font-family: monospace;&quot;&gt;results in :&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;!=&amp;nbsp;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Logical Operator:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Logical operator evaluates two Java boolean values and gives results in boolean value. There are three logical operator in Java. Below is the code that shows the basics of logical operators.&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Logical&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;boolean&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;true&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;boolean&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;b&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #2a00ff; font-family: monospace;&quot;&gt;results in :&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;a&amp;nbsp;||&amp;nbsp;b&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #2a00ff; font-family: monospace;&quot;&gt;results in :&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&amp;nbsp;||&amp;nbsp;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;!a&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #2a00ff; font-family: monospace;&quot;&gt;results in :&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&amp;nbsp;&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;!a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u style=&quot;font-weight: bold;&quot;&gt;Truth table for and or and not operations:&lt;/u&gt;&amp;nbsp;Here P and Q are&amp;nbsp;Boolean&amp;nbsp;expressions and T stands for&lt;i&gt; true&lt;/i&gt; and F stands for &lt;i&gt;false&lt;/i&gt;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY6UMiHAnxWenJ60rVvGi6G9QXR4M2TpjS47AjyCeVdZqyEVpJKP9G28uvat05yMSDIq8ajyA278BhGpmG9tTQKlf1p7HCnqDAroo04UPokF72ZlzmUUPZsRm-dhrsiXG8Ru787TUJEY4/s1600/and+or+not+truth+table.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY6UMiHAnxWenJ60rVvGi6G9QXR4M2TpjS47AjyCeVdZqyEVpJKP9G28uvat05yMSDIq8ajyA278BhGpmG9tTQKlf1p7HCnqDAroo04UPokF72ZlzmUUPZsRm-dhrsiXG8Ru787TUJEY4/s1600/and+or+not+truth+table.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;&lt;u&gt;Conditional Operator:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Conditional Operator is a ternary operator in Java which evaluates a expression&amp;nbsp;and returns option1 if result is true else returns option2. Take a Look at the figure below.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizCE1v49xYndWjUHssmYBvaIANWl-T0pVo-tiazc1BAxE77GOZqIbL8OeSPY08f3wyHeUDgYxhyphenhyphenxGq79cIm0eWSzYW7gQkOxzvCX6XOJBcnZsYXDCyUQy2PS8N_ejBfWBtHVpHRMUWmdw/s1600/Conditional+Operator.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizCE1v49xYndWjUHssmYBvaIANWl-T0pVo-tiazc1BAxE77GOZqIbL8OeSPY08f3wyHeUDgYxhyphenhyphenxGq79cIm0eWSzYW7gQkOxzvCX6XOJBcnZsYXDCyUQy2PS8N_ejBfWBtHVpHRMUWmdw/s1600/Conditional+Operator.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt;&lt;b style=&quot;color: #7f0055;&quot;&gt;public&amp;nbsp;class &lt;/b&gt;Conditional&amp;nbsp;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;max;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;max=&amp;nbsp;a&amp;nbsp;&amp;gt;&amp;nbsp;b&amp;nbsp;?&amp;nbsp;a&amp;nbsp;:&amp;nbsp;b&amp;nbsp;;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Max =&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&amp;nbsp;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/7570707742003007890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-operators.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7570707742003007890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7570707742003007890'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-operators.html' title='JAVA Programming : Operators'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEiY6UMiHAnxWenJ60rVvGi6G9QXR4M2TpjS47AjyCeVdZqyEVpJKP9G28uvat05yMSDIq8ajyA278BhGpmG9tTQKlf1p7HCnqDAroo04UPokF72ZlzmUUPZsRm-dhrsiXG8Ru787TUJEY4/s72-c/and+or+not+truth+table.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-8881638711253340107</id><published>2011-04-16T13:05:00.000-07:00</published><updated>2011-04-19T02:53:37.162-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Using Scanner for User Input</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;color: #333333; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large; line-height: 20px;&quot;&gt;&lt;b&gt;JAVA Scanner&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;As we now know a little bit about&amp;nbsp;Java programming we will start making our first program.&amp;nbsp;&amp;nbsp;In this tutorial we learn how to get input from user. There are a number of ways for taking input form user in Java and one way is using &lt;i style=&quot;font-weight: bold;&quot;&gt;Scanner. &lt;/i&gt;A Scanner class is already built in Java and present in the &lt;i&gt;java.util&lt;/i&gt; package. A scanner takes input from various types of Input Streams.&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Creating a Scanner Objec&lt;/b&gt;t:&lt;br /&gt;
Lets create a scanner object that accepts systems.in as input stream it means that scanner will take input from console.&amp;nbsp;&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Courier; font-size: 11px; line-height: 16px; white-space: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;System.in is an InputStream &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;A scanner can take various types as input stream for example, here we have a File Reader as input stream that reads data from a file named as MyFile.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scanfile =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;FileReader(&quot;MyFile&quot;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Courier; font-size: 11px; line-height: 16px; white-space: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Getting User Input form Console using Scanner : &lt;/b&gt;Lets create a class that take two integer input from user and prints their sum. To use the Scanner class, first we need to import it. Take a look at the code :&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.util.Scanner;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;UserInput&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;second&amp;nbsp;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;first;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;total;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&amp;nbsp;scan&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Scanner&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.in&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;enter&amp;nbsp;1st&amp;nbsp;no.&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;first&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//stores&amp;nbsp;user&amp;nbsp;input&amp;nbsp;into&amp;nbsp;first &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;enter&amp;nbsp;2nd&amp;nbsp;no.&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;second&amp;nbsp;=&amp;nbsp;scan.nextInt&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//stores&amp;nbsp;user&amp;nbsp;input&amp;nbsp;into&amp;nbsp;second&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3f7f5f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;total&amp;nbsp;=&amp;nbsp;first&amp;nbsp;+&amp;nbsp;second&amp;nbsp;;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//sum&amp;nbsp;of&amp;nbsp;first&amp;nbsp;and&amp;nbsp;second&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;sum&amp;nbsp;=&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;total&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;In the first line of code, we have an import statement to import Scanner class. Now we can use the Scanner class anywhere in our code. In our class we have three int variables first, second and total. Variable first and second will hold the user input and total will hold their sum.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;To take integer input scanner has a method called nextInt. This methods reads the integer input by user. In the above code we have used this method two times and to save user input in int variables first and second.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Output of Program :&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwEaJQRhFOinVP9SQcw_pnGcmiujkHw6LqYe6EiE5Er_4RSytSjStQ_NxvjZgALwaxBfwaQrg41iuNPppzpLzrEkkNX0Imic9QTITEaSSJms2BDmEX7K7osX99ckpbtF9iIhoyGF24wr8/s1600/Scanner.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwEaJQRhFOinVP9SQcw_pnGcmiujkHw6LqYe6EiE5Er_4RSytSjStQ_NxvjZgALwaxBfwaQrg41iuNPppzpLzrEkkNX0Imic9QTITEaSSJms2BDmEX7K7osX99ckpbtF9iIhoyGF24wr8/s1600/Scanner.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Note that if are using nextInt method and the input given is not integer, then compiler will give an error. There are some other methods that are used for different types of input.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-bottom-style: none; border-collapse: collapse; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 0.5pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: windowtext; border-top-style: solid; border-top-width: 0.5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 149.4pt;&quot; valign=&quot;top&quot; width=&quot;149&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;Method&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: initial; border-left-style: none; border-left-width: initial; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: windowtext; border-top-style: solid; border-top-width: 0.5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 247.5pt;&quot; valign=&quot;top&quot; width=&quot;248&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;Reads&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 0.5pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 149.4pt;&quot; valign=&quot;top&quot; width=&quot;149&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;int nextInt()&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: initial; border-left-style: none; border-left-width: initial; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 247.5pt;&quot; valign=&quot;top&quot; width=&quot;248&quot;&gt;&lt;div class=&quot;Tnoindent&quot; style=&quot;line-height: 13pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Reads the next input as an&amp;nbsp;int. If the input is not an integer,InputMismatchException&amp;nbsp;is thrown.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 0.5pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 149.4pt;&quot; valign=&quot;top&quot; width=&quot;149&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;long nextLong()&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: initial; border-left-style: none; border-left-width: initial; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 247.5pt;&quot; valign=&quot;top&quot; width=&quot;248&quot;&gt;&lt;div class=&quot;Tnoindent&quot; style=&quot;line-height: 13pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Reads the next token as a&amp;nbsp;long. If the next token is not an long,InputMismatchException&amp;nbsp;is thrown.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 0.5pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 149.4pt;&quot; valign=&quot;top&quot; width=&quot;149&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;float nextFloat()&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: initial; border-left-style: none; border-left-width: initial; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 247.5pt;&quot; valign=&quot;top&quot; width=&quot;248&quot;&gt;&lt;div class=&quot;Tnoindent&quot; style=&quot;line-height: 13pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Reads the next input as a&amp;nbsp;float. If the input is not a float,&amp;nbsp;InputMismatchException&amp;nbsp;is thrown.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 0.5pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 149.4pt;&quot; valign=&quot;top&quot; width=&quot;149&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;double nextDouble()&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: initial; border-left-style: none; border-left-width: initial; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 247.5pt;&quot; valign=&quot;top&quot; width=&quot;248&quot;&gt;&lt;div class=&quot;Tnoindent&quot; style=&quot;line-height: 13pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Reads the next input as a&amp;nbsp;double. If the input is not a double,&amp;nbsp;InputMismatchException&amp;nbsp;is thrown.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 0.5pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 149.4pt;&quot; valign=&quot;top&quot; width=&quot;149&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;String next()&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: initial; border-left-style: none; border-left-width: initial; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 247.5pt;&quot; valign=&quot;top&quot; width=&quot;248&quot;&gt;&lt;div class=&quot;Tnoindent&quot; style=&quot;line-height: 13pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Finds and returns the next complete token from this scanner and returns it as a string; a token is usually ended by whitespace such as a blank or line break.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 0.5pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 149.4pt;&quot; valign=&quot;top&quot; width=&quot;149&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;String nextLine()&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: initial; border-left-style: none; border-left-width: initial; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 247.5pt;&quot; valign=&quot;top&quot; width=&quot;248&quot;&gt;&lt;div class=&quot;Tnoindent&quot; style=&quot;line-height: 13pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Reads the rest of the current line, excluding any line separator at the end.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 0.5pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 149.4pt;&quot; valign=&quot;top&quot; width=&quot;149&quot;&gt;&lt;div class=&quot;cdmid&quot; style=&quot;line-height: 12pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;void close()&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 0.5pt; border-left-color: initial; border-left-style: none; border-left-width: initial; border-right-color: windowtext; border-right-style: solid; border-right-width: 0.5pt; border-top-color: initial; border-top-style: none; border-top-width: initial; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 247.5pt;&quot; valign=&quot;top&quot; width=&quot;248&quot;&gt;&lt;div class=&quot;Tnoindent&quot; style=&quot;line-height: 13pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Closes the scanner.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/8881638711253340107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-using-scanner-for-user.html#comment-form' title='22 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/8881638711253340107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/8881638711253340107'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-using-scanner-for-user.html' title='JAVA Programming : Using Scanner for User Input'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEiwEaJQRhFOinVP9SQcw_pnGcmiujkHw6LqYe6EiE5Er_4RSytSjStQ_NxvjZgALwaxBfwaQrg41iuNPppzpLzrEkkNX0Imic9QTITEaSSJms2BDmEX7K7osX99ckpbtF9iIhoyGF24wr8/s72-c/Scanner.JPG" height="72" width="72"/><thr:total>22</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-7486778868388158700</id><published>2011-04-16T11:16:00.000-07:00</published><updated>2011-04-16T11:17:25.110-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Interface</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;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Interface&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Interfaces are declared using the interface keyword and they are like a pure abstract class i.e. every method in an Interface is an abstract method. An interface can not be&amp;nbsp;instantiated they can only be implemented by other classes or can be extended by other&amp;nbsp;interfaces.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Implementing a interface by a class is like making a contract that the class will implement all the methods of that interface. If a class does not implement all the methods of an implemented interface, the Java Compiler will give an error.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Syntax of&amp;nbsp;a Interface&lt;/b&gt;:-&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;[&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;access&amp;nbsp;identifier&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;]&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;interface&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;InterfaceName&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;[&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;extends &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Interface1, Interface2....&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;]&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #274e13;&quot;&gt;//adstrace&amp;nbsp;method&amp;nbsp;declarations&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;NOTE: Because all methods in an interface is abstract by&amp;nbsp;definition&amp;nbsp;so their is no need to declare them abstract by using abstract keyword.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;b&gt;Declaring a Interface:-&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;For example, lets create a interface Record which has three methods add,&amp;nbsp;update and delete.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;interface&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Record&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;delete&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Lets create a class Employee that implements the interface Record. Employee class must implement all the methods of Record interface.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Employee&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: #7f0055;&quot;&gt;implements &lt;/b&gt;Record&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{ &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3f7f5f; font-family: monospace;&quot;&gt;// fields and methods of class&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3f7f5f;&quot;&gt;// methods of Record interface&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;set&amp;nbsp;of&amp;nbsp;java&amp;nbsp;statements&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;delete&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;set&amp;nbsp;of&amp;nbsp;java&amp;nbsp;statements&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;set&amp;nbsp;of&amp;nbsp;java&amp;nbsp;statements&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/7486778868388158700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-interface.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7486778868388158700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7486778868388158700'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-interface.html' title='JAVA Programming : Interface'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-3704258544354025731</id><published>2011-04-12T10:36:00.000-07:00</published><updated>2011-04-12T10:36:47.710-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Abstract Class and Abstract Method</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Abstract Classes and Abstract Methods&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Abstract Class:&lt;/b&gt; An abstract class is declared using abstract keyword. An abstract class is a class&amp;nbsp;definition&amp;nbsp;that is incomplete in the sense that it has some abstract methods. It is not&amp;nbsp;compulsory&amp;nbsp;that an&amp;nbsp;abstract class has an abstract method but if a class has an abstract method, the class has to be declared as abstract. Abstract classes can never be&amp;nbsp;initiated but they can be&amp;nbsp;subclassed.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Abstract Method: &lt;/b&gt;Abstract method are declared using abstract keyword.&amp;nbsp;Abstract methods are defined as part of the class but the inner workings (body of methods) are not provided. Abstract&amp;nbsp;methods&amp;nbsp;ends with semicolon instead of curly brackets.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;text-align: justify;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td nowrap=&quot;nowrap&quot; style=&quot;text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp; public&amp;nbsp;abstract&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Bike&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{ &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;abstract&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;gear&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;abstract&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;topSpeed&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Why we need an Abstract Class: &lt;/b&gt;This is the question that many people ask about, what is the need of abstract class. The idea behind an abstract class is putting common functionality to an abstract class that other classes will extend.&lt;br /&gt;
For example we can have a abstract class named fan with a method for turning the fan on and off but&amp;nbsp;not defining the&amp;nbsp;procedure&amp;nbsp;to do that&amp;nbsp;i.e.&amp;nbsp;with no body&amp;nbsp;declaration. Now we can extend the fan class into table fan and define on and off procedure accordingly or we can extend the fan class to&amp;nbsp;ceiling fan and&amp;nbsp;define on and off procedure according to ceiling fan.&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/3704258544354025731/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-abstract-class-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/3704258544354025731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/3704258544354025731'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-abstract-class-and.html' title='JAVA Programming : Abstract Class and Abstract Method'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-1413611018043718462</id><published>2011-04-11T09:21:00.000-07:00</published><updated>2011-04-12T08:32:20.548-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Variables and Scope of Variables</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Variables&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;br /&gt;
A variable in Java is like place holder that can store a value that once declared can be used through out the program according to scope of that variable(discussed&amp;nbsp;below). Datatypes specifies what kind of data each variables will store for example a variable declared as &lt;i&gt;int&lt;/i&gt; cannot have &lt;i&gt;char&lt;/i&gt; values.&amp;nbsp;&lt;/div&gt;&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;DeclareVariables&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;sum;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;sum&amp;nbsp;=&amp;nbsp;a+b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;sum&amp;nbsp;=&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+sum&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;
In DeclareVariable class, inside the main method we declared three &lt;i&gt;int&lt;/i&gt; variables &lt;i&gt;a, b&lt;/i&gt; and &lt;i&gt;sum. &lt;/i&gt;Here &lt;i&gt;a&lt;/i&gt; and &lt;i&gt;b &lt;/i&gt;variables has some value stored and variable&amp;nbsp;&lt;i&gt;sum&lt;/i&gt; will have their&amp;nbsp;addition&amp;nbsp;stored in it. Output of this Java program is:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDfEX1d7XLZSD5rsnipBIEf4Fvd2olxcQRBTg2Avb10hPyyI4ybRmySh_E8gVgmNPI-GZBmMz6HgQzrJvCXDPv07fP7Cj25velJ-eK3aEt_CjYcTNhwpEfdpWYrcHZhyphenhyphenbZWHtUaDoN3zc/s1600/Java+Variables.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;171&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDfEX1d7XLZSD5rsnipBIEf4Fvd2olxcQRBTg2Avb10hPyyI4ybRmySh_E8gVgmNPI-GZBmMz6HgQzrJvCXDPv07fP7Cj25velJ-eK3aEt_CjYcTNhwpEfdpWYrcHZhyphenhyphenbZWHtUaDoN3zc/s640/Java+Variables.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Scope of Variables&lt;/u&gt;&lt;/b&gt;: Scope of variables is the portion of program where a declared variable can be used. Scope of Variable&amp;nbsp;differ according to the place where the variable is declared. A variable can be declared in various places in a Java Class.&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Class Body&lt;/li&gt;
&lt;li&gt;Method Body&lt;/li&gt;
&lt;li&gt;With in Statement Block&lt;/li&gt;
&lt;li&gt;As Parameter or in for loops&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;First three declared variables will have there scope with in the block (curly brackets) they are declared. The variable declared as parameter or in for loops are declared with in P&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: 12px; line-height: 18px;&quot;&gt;&lt;span class=&quot;toctext&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: sans-serif;&quot;&gt;arentheses&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;and can be used with in the followed statement block.&amp;nbsp;&lt;/div&gt;&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ScopeOfVariables&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;a&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;a++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&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;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
In above example we have a variable declared in for loop that can used only with in the statement block of that for loop.&amp;nbsp;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/1413611018043718462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-variables-and-scope-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1413611018043718462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1413611018043718462'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/04/java-programming-variables-and-scope-of.html' title='JAVA Programming : Variables and Scope of Variables'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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/AVvXsEgDfEX1d7XLZSD5rsnipBIEf4Fvd2olxcQRBTg2Avb10hPyyI4ybRmySh_E8gVgmNPI-GZBmMz6HgQzrJvCXDPv07fP7Cj25velJ-eK3aEt_CjYcTNhwpEfdpWYrcHZhyphenhyphenbZWHtUaDoN3zc/s72-c/Java+Variables.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5879038844944713475.post-5426859185608643986</id><published>2011-03-21T05:05:00.000-07:00</published><updated>2012-02-18T05:40:17.160-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Data Types</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&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;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Data Types&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&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;Java has a number of data types below is the complete list of them . Although syntax of Java is largely derived from C++ but datatypes are a bit different from C for example C does not have Boolean data type. Java Datatypes have a fixed size and also some default values that will bet set to variables if they are declared but not initialized.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Boolean&lt;/b&gt; : Boolean datatype does not have a specific size declared but conceptually it has one bit value. Boolean datatypes has only two possible values true or false. Default value for Booleans are false.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Size:- not defined&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Values:- true or false&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Default value:- false&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Char: &lt;/b&gt;A char is 16 bit value that can be treated like an integer value but is&amp;nbsp;intended&amp;nbsp;to hold characters. In a Java program a char datatype is always interpreted as a numeric value of a displayable character.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Size:- 16 bit&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Values:- from 0 to 65535&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Default value:- 0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Byte&lt;/b&gt;: A byte is an 8 bit integer value.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Size:- 8 bit&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Values:- from -128 to 127&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Default value:- 0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Sort&lt;/b&gt;:&amp;nbsp;A sort is an 16 bit integer value.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Size:- 16 bit&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Values:- from -32768 to 32767&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Default value:- 0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Int&lt;/b&gt;:&amp;nbsp;A int is an 32 bit integer value.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Size:- 32 bit&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Values:- from -2147483648 to&amp;nbsp;2147483647&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Default value:- 0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;long&lt;/b&gt;:&amp;nbsp;A Long is an 64 bit integer value and it is the largest of all the integer types.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Size:- 64 bit&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Values:- from -9,223,372,036,854,775,808&amp;nbsp;to&amp;nbsp;9,223,372,036,854,775,807&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Default value:- 0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;float&lt;/b&gt;: A float is 32 bit single precision floating point decimal number.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Size:- 32 bit&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Values:- from -1.4E-45 to 3.4028235E38&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Default value:- 0.0&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;double&lt;/b&gt;: Double is 64 bit double precision floating point decimal number.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Size:- 64 bit&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Values:- from -4.9E-324 to 1.7976931348623157E308&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Default value:- 0.0&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/5426859185608643986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/03/java-programming-data-types.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/5426859185608643986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/5426859185608643986'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/03/java-programming-data-types.html' title='JAVA Programming : Data Types'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-2009375983535684414</id><published>2011-03-18T14:50:00.000-07:00</published><updated>2011-03-20T08:46:56.524-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Hello World</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Hello World Program&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;A Java Hello World program is the traditional program that you will find everywhere on the web and this &amp;nbsp;program is probably the simplest program that you can write and make it actually do something. Hello World program doesn&#39;t do much, it just displays one line of text on the screen but it is a complete java program that will actually compile and run. &lt;/div&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Source Code of Hello World Java program:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp; public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;HelloWorld&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]){ &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Hello&amp;nbsp;World&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;//prints a line on screen&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;A Closer look at Hello World Program :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;The first line of the code declares a public class named HelloWorld. Declaring a class public means that it can be accessed by name form any place (talk more about Access&amp;nbsp;specifiers&amp;nbsp;letter). In second line we declare a main method. Every class file that can be executed form command line should have a main method just like this one. When ever we run a Java program the compilers looks for a main method to starts with. A main method is always declared as &lt;i&gt;&lt;b&gt;public&lt;/b&gt; &lt;/i&gt;so that it can be&amp;nbsp;accessible&amp;nbsp;from any where and &lt;b style=&quot;font-style: italic;&quot;&gt;static &lt;/b&gt;so it exist without a object being created. The main method takes a string array&amp;nbsp;argument&amp;nbsp;as parameter. We can pass a string array from command line at the time of running java program. Now inside the main method there is only one line of code that calls to the println method that prints a line of text.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The text that written after the &quot;System.out.println(&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Hello World&lt;/span&gt;&quot;);&quot; is known as &lt;b&gt;&lt;i&gt;comment&lt;/i&gt;&lt;/b&gt;.&amp;nbsp;A Comment is not part of the actual code i.e. the compiler will not compile a comment.&amp;nbsp;Comments are only used for increasing the readability of code.&amp;nbsp;To make something a comment use two forward slashes(//) in front of it.&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/2009375983535684414/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/03/java-programming-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2009375983535684414'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/2009375983535684414'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/03/java-programming-hello-world.html' title='JAVA Programming : Hello World'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-1192834416030101776</id><published>2011-03-17T18:23:00.000-07:00</published><updated>2011-03-20T08:47:40.082-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Naming Rules and Conventions</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;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Naming Rules and Conventions&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: justify;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&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;Before we start writing any Java Program or code we must know about some naming rules and convention of Java, so first we talk about some rules.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Java Naming Rules:&lt;/u&gt;&amp;nbsp;Below are the set of rules that you must follow to write a error free code.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Java is Case Sensitive language&lt;/b&gt; that means that upper case latter and lower case latter are two different things. In &amp;nbsp;other words we can say that in Java there are 52 characters (26 upper and 26 lower case). For example&lt;i&gt; JAVACODESPOT&lt;/i&gt; , &lt;i&gt;JavaCodeSpot &lt;/i&gt;and &lt;i&gt;javacodespot&lt;/i&gt; will be treated as different identifiers in Java.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;First Character &lt;/b&gt;of any name can be any of these:&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;a-z (any lower case&amp;nbsp;alphabets)&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;A-Z&amp;nbsp;(any lower case&amp;nbsp;alphabets)&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;$ (A dollar sign)&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;_ (Underscore sign)&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Note: the first character of any name &lt;i&gt;can not be digit (0-9)&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;After first character a name can be anything that a first&amp;nbsp;character&amp;nbsp;can be and it can have a digit or number (0-9) also.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;u style=&quot;font-weight: bold;&quot;&gt;Java Naming Conventions:&lt;/u&gt;&amp;nbsp;Bellow are the set of&amp;nbsp;standards that are given by Sun that programmer should follow to make their code easier to read for themselves and for other programmers.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;For Classes and Interfaces&lt;/span&gt;&lt;i style=&quot;font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/i&gt;the first letter of the name&amp;nbsp;should be capitalized and if the name is made up with several words, start of every word should be capitalized for example &lt;i&gt;Dog&lt;/i&gt;, &lt;i&gt;CamelCase&lt;/i&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;For Methods and Variables&lt;/b&gt; the first word of the name should be lowercase and if the name is made up with several words, start of every word except first word should be capitalized for example &lt;i&gt;dog&lt;/i&gt;, &lt;i&gt;camelCase&lt;/i&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;For Constant&lt;/b&gt; there is no predefined type in Java but you can have a constant by declaring variable &lt;i&gt;static &lt;/i&gt;and &lt;i&gt;final. &lt;/i&gt;A Constant name should be of uppercase and if the name is made up with several words the underscore should be used between the words for example &lt;i&gt;DOG, CAMEL_CASE&lt;/i&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;For Packages&lt;/b&gt;&amp;nbsp;names should be in lowercase and full stop (.) as&amp;nbsp;separator.&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/1192834416030101776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/03/java-programming-naming-rules-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1192834416030101776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1192834416030101776'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/03/java-programming-naming-rules-and.html' title='JAVA Programming : Naming Rules and Conventions'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-1839546035012171248</id><published>2011-03-17T13:26:00.000-07:00</published><updated>2011-03-17T13:34:08.686-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Methods</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Methods&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;A Java method contains set of Java statements which is declared inside a Java class.&amp;nbsp;Methods are where class logic is&amp;nbsp;stored&amp;nbsp;or where the actual work gets done.&amp;nbsp;Java methods are similar to functions or procedures in other programming languages.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;A Java method declaration various parts like Modifiers, Return Type, Method name, parameter and and there is one more thing exceptions that can also be part of a method.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;Syntex of a Java Method :&lt;/b&gt;&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;Modifier ReturnType MethodName ( Parameters ){ &amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// set of java statements &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;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;b&gt;Example of a Java Method :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;giveSum&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;a,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){ &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ans&amp;nbsp;=&amp;nbsp;a&amp;nbsp;+&amp;nbsp;b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ans;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
Once a method is defined, it can be called with in a Java class just by writing name of the method followed by parameters in the brackets according to method&amp;nbsp;definition and followed by a semicolon. For example if above method giveSum is to called then :&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; giveSum(10,20); &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #93c47d;&quot;&gt;//calling a method&lt;/span&gt; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/1839546035012171248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/03/java-programming-methods.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1839546035012171248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1839546035012171248'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/03/java-programming-methods.html' title='JAVA Programming : Methods'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-6076946793493134902</id><published>2011-01-30T12:18:00.000-08:00</published><updated>2011-02-01T05:41:10.321-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Object</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Objects&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;As you know from the&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;a href=&quot;http://javacodespot.blogspot.com/2011/01/java-class.html&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;previous post&lt;/span&gt;&lt;/a&gt;,&lt;/span&gt; class is a blueprint for object. So, an Object is an instance of class that &lt;b&gt;&lt;i&gt;Java Virtual Machine (JVM)&lt;/i&gt;&lt;/b&gt; create at runtime whenever it finds an &lt;b&gt;&lt;i&gt;new&lt;/i&gt;&lt;/b&gt; keyword. Every object will have &lt;i style=&quot;font-weight: bold;&quot;&gt;state &lt;/i&gt;and &lt;i style=&quot;font-weight: bold;&quot;&gt;behavior&lt;/i&gt;&amp;nbsp;defined in its class.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;To understand software objects, first we look at some example of real world object like a &lt;i&gt;Fan. &lt;/i&gt;A fan will have its own state like motor, blade, power switch etc. and behavior like speed, on or off etc. In the same way there are software objects that too have state in form of fields or variables and behavior in form of methods or functions.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;u&gt;Creating an Object:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
For example we take a Television class and create its object.&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-text-decorations-in-effect: none; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Television&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;the&amp;nbsp;Television&amp;nbsp;class&amp;nbsp;has&amp;nbsp;two&amp;nbsp;fields&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;size;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;&amp;nbsp;colorType;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;the&amp;nbsp;Television&amp;nbsp;class&amp;nbsp;has&amp;nbsp;one&amp;nbsp;constructor&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Television&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;tvSize,&amp;nbsp;String&amp;nbsp;tvColorType&lt;/span&gt;&lt;span style=&quot;color: black;&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;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;size&amp;nbsp;=&amp;nbsp;tvSize;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;colorType&amp;nbsp;=&amp;nbsp;tvColorType;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;&amp;nbsp;A object of television class can be created in this way:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Television&amp;nbsp;tv =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Television&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Color TV&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
In a object Declaration Statement there is three part&lt;br /&gt;
&lt;b&gt;1.&amp;nbsp;Declaration of object :&lt;/b&gt; Part of statement before the &#39;=&#39; sign is Declaration part of object.&lt;br /&gt;
&lt;b&gt;2. Instantiation :&lt;/b&gt; The new keyword in Java does the instantiation of an object.&lt;br /&gt;
&lt;b&gt;3.&amp;nbsp;Initialization&amp;nbsp;: &lt;/b&gt;After new keyword there is call to construction of class which does the&amp;nbsp;initialization.&lt;br /&gt;
&lt;br /&gt;
It is not&amp;nbsp;necessary that declaration part is to followed by instantiation and&amp;nbsp;initialization part.&amp;nbsp;Like other variable declarations, object declarations can be done alone.&amp;nbsp;A object declaration can be done in this way :&lt;br /&gt;
&lt;br /&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Television&amp;nbsp;tv; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tv =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Television&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Color TV&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&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;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/6076946793493134902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/01/java-programming-object.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/6076946793493134902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/6076946793493134902'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/01/java-programming-object.html' title='JAVA Programming : Object'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-1055041036579562244</id><published>2011-01-19T05:34:00.000-08:00</published><updated>2011-02-01T05:42:39.095-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Java Programming Course"/><title type='text'>JAVA Programming : Class</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Class&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot; /&gt;&lt;div style=&quot;display: block; float: right;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;&lt;b&gt;Class&lt;/b&gt; in &lt;b&gt;Java&lt;/b&gt; is a template that describes the kind of &lt;b&gt;state&lt;/b&gt; and&lt;b&gt;&amp;nbsp;behavior&lt;/b&gt;&amp;nbsp;that &lt;b&gt;&lt;a href=&quot;http://javacodespot.blogspot.com/2011/01/java-programming-object.html&quot;&gt;objects&lt;/a&gt;&lt;/b&gt; of its type support. In simple words a Class is an blueprint from which an object is constructed.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;For Example think of a Blueprint of a house. A class for an object is like a blueprint for a house. A blueprint can be used to build a lot of hoses and a class can be used to build a lot of object.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;Things defines inside the class are said to be member of the class and when&amp;nbsp;the objects are&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;constructed from the class, the member of class also become member of each object.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;A &lt;b&gt;Class declaration&lt;/b&gt; can be done in this way:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;java&quot;&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;
&lt;code&gt; &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Television&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;the&amp;nbsp;Television&amp;nbsp;class&amp;nbsp;has&amp;nbsp;two&amp;nbsp;fields&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;size;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;&amp;nbsp;colorType;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;the&amp;nbsp;Television&amp;nbsp;class&amp;nbsp;has&amp;nbsp;one&amp;nbsp;constructor&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Television&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;tvSize,&amp;nbsp;String&amp;nbsp;tvColorType&lt;/span&gt;&lt;span style=&quot;color: black;&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;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;size&amp;nbsp;=&amp;nbsp;tvSize;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;colorType&amp;nbsp;=&amp;nbsp;tvColorType;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;the&amp;nbsp;Television&amp;nbsp;class&amp;nbsp;has&amp;nbsp;two&amp;nbsp;methods&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;setSize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;newValue&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;size&amp;nbsp;=&amp;nbsp;newValue;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;setColorType&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;newValue&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;colorType&amp;nbsp;=&amp;nbsp;newValue;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;       &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Java Subclass :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Subclass in Java is a class that is an&amp;nbsp;extension of an existing class. In other words Subclass is a class that extends another class. A Subclass is also known as &lt;b&gt;Derived Class&lt;/b&gt; or &lt;b&gt;Child Class&lt;/b&gt;.&lt;br /&gt;
A Subclass will inherits all properties like variables and methods of &lt;b&gt;Extended Class&lt;/b&gt; or &lt;b&gt;Super Class&lt;/b&gt;.&lt;br /&gt;
For example, we make a Class LcdTv which extends the class Television. Now the LcdTv class will have all the properties of Television so we don&#39;t need to write them again but LcdTv class has one extra property contrastRatio that is not present in Television Class, so we need to declare that field in LcdTv class.&lt;br /&gt;
&lt;br /&gt;
&lt;div align=&quot;left&quot; class=&quot;java&quot;&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;LcdTv&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;extends&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Television&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;the&amp;nbsp;LcdTv&amp;nbsp;subclass&amp;nbsp;has&amp;nbsp;one&amp;nbsp;field&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;contrastRatio;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;the&amp;nbsp;LcdTv&amp;nbsp;subclass&amp;nbsp;has&amp;nbsp;one&amp;nbsp;constructor&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;LcdTv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;tvSize,&amp;nbsp;String&amp;nbsp;tvColorType,&amp;nbsp;String&amp;nbsp;tvContrastRatio&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;super&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;tvSize,&amp;nbsp;tvColorType&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;contrastRatio&amp;nbsp;=&amp;nbsp;tvContrastRatio;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;the&amp;nbsp;LcdTv&amp;nbsp;subclass&amp;nbsp;has&amp;nbsp;one&amp;nbsp;method&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;setHeight&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;newValue&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;contrastRatio&amp;nbsp;=&amp;nbsp;newValue;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/1055041036579562244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/01/java-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1055041036579562244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/1055041036579562244'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/01/java-class.html' title='JAVA Programming : Class'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-8476557663110400811</id><published>2011-01-02T11:46:00.000-08:00</published><updated>2011-01-14T10:39:01.338-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Version Checker"/><title type='text'>JAVA : Version Checker</title><content type='html'>&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; font-weight: normal; line-height: 20px;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Version Checker&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot; /&gt;&lt;b&gt;What Version of Java is Running on your System?&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;To Know answer that &lt;b&gt;Java Code Spot&lt;/b&gt; has wrote a simple &lt;b&gt;Java Version checker Application &lt;/b&gt;that tells what version of Java is currently running on your system. Your system has the information about the version of Java installed and you can get that inforamtion for Java Runtime Enviornment of your system. Version checker Applet also displays some other information like Vendor of Java, Operating system, OS Version and OS Architecture.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizental link add */
google_ad_slot = &quot;3971116404&quot;;
google_ad_width = 728;
google_ad_height = 15;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;applet code=&quot;JavaVer.class&quot; codebase=&quot;http://javacodespot.741.com/JavaVersion/&quot; height=&quot;155&quot; width=&quot;300&quot;&gt;&lt;/applet&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-text-decorations-in-effect: none; color: #333333; font-family: Georgia, serif; font-size: 13px; font-weight: bold; line-height: 20px;&quot;&gt;!!!!!!!!!!....Applet may take some time to load....!!!!!!!!!!&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
If You have Java installed and&amp;nbsp;enabled&amp;nbsp;in your browser you will see a pink color rectangle above with information displaying. If you don&#39;t see a pink rectangle it means Java may not be installed.&lt;br /&gt;
&lt;br /&gt;
In this application we are getting information about Java and Operation System by a simple code&lt;br /&gt;
System.getProperty(String Key);&lt;br /&gt;
&lt;br /&gt;
This method is used to get System properties according to parameter given in String.&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* hori leaderboard text */
google_ad_slot = &quot;3514705799&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;b&gt;Java Code to get System Information:&lt;/b&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-bottom-style: none; border-collapse: collapse; border-left-style: none; border-right-style: none; border-top-style: none; margin-left: 6.9pt; width: 600px;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 57.25pt;&quot;&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 1pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 1pt; border-top-color: windowtext; border-top-style: solid; border-top-width: 1pt; height: 57.25pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 517.55pt;&quot; valign=&quot;top&quot; width=&quot;600&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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; System.&lt;i&gt;getProperty&lt;/i&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&quot;java.version&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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; System.&lt;i&gt;getProperty&lt;/i&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&quot;java.vendor&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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; System.&lt;i&gt;getProperty&lt;/i&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&quot;os.name&lt;/span&gt;&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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; System&lt;i&gt;.getProperty&lt;/i&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&quot;os.version&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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; System.&lt;i&gt;getProperty&lt;/i&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&quot;os.arch&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
You can also get some other information using this method&lt;br /&gt;
&lt;br /&gt;
S/No. &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Key&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Description&lt;br /&gt;
---------------------------------------------------------------------------------------------------------&lt;br /&gt;
1&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; java.version&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; The version of Java Runtime Environment.&lt;br /&gt;
2&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;java.vendor &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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;The name of Java Runtime Environment vendor&lt;br /&gt;
3&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;java.vendor.url &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The URL of Java vendor&lt;br /&gt;
4&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; java.home&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; The directory of Java installation&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;5&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;user.name&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; The name of account name user&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;6 &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; user.home&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; The home directory of user&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;7 &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; user.dir&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; &amp;nbsp; &amp;nbsp;The current working directory of the user&lt;/div&gt;8&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;java.vm.version &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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;JVM implementation version&lt;br /&gt;
9&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;java.vm.vendor&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; JVM implementation vendor&lt;br /&gt;
10&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; java.vm.name &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; JVM &amp;nbsp;implementation name&lt;br /&gt;
11&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; java.specification.version &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The name of specification version Java Runtime Environment&lt;br /&gt;
12&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; java.specification.vendor&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JRE specification vendor&lt;br /&gt;
13&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; java.class.version&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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;Java class format version number&lt;br /&gt;
14&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; java.class.path&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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;Path of java class&lt;br /&gt;
15&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; java.library.path&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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;List of paths to search when loading libraries&lt;br /&gt;
16&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; java.io.tmpdir&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; The path of temp file&lt;br /&gt;
17&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; java.compiler&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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;The Name of JIT compiler to use&lt;br /&gt;
18&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; os.name &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; &amp;nbsp;The name of OS name&lt;br /&gt;
19&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; os.arch &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; &amp;nbsp; &amp;nbsp;The OS architecture&lt;br /&gt;
20&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; os.version &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&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; The version of OS&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;color: #333333; font-family: Georgia, serif; font-size: 18px; font-weight: normal; line-height: 1.4em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0.25em; padding-bottom: 4px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative;&quot;&gt;Download Files Here:&lt;/h3&gt;&lt;ul style=&quot;color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 1.4; list-style-image: initial; list-style-position: initial; list-style-type: disc; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;&quot;&gt;&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-top-color: initial; border-top-style: none; border-width: initial; border-width: initial; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;a href=&quot;http://javacodespot.110mb.com/JavaVersionChecker.zip&quot; style=&quot;color: #336688; text-decoration: none;&quot; title=&quot;Source Code of Typing Test Application&quot;&gt;Download Source Code of &amp;nbsp;JAVA Version Checker Application (File Size: 2Kb)&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/8476557663110400811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2011/01/java-version-checker.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/8476557663110400811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/8476557663110400811'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2011/01/java-version-checker.html' title='JAVA : Version Checker'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-7892113978306787296</id><published>2010-12-15T11:01:00.000-08:00</published><updated>2011-01-14T10:40:15.303-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Font Formatter"/><title type='text'>JAVA : Font Formatter</title><content type='html'>&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Font Formatter&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;hr style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot; /&gt;Font Formatter is a Java application that allows user to manipulate font in different ways like font type, font size, and font style. This Font Formatter Java application shows the use of font utility that can be used in many other programs.&lt;br /&gt;
&lt;div align=&quot;center&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;applet code=&quot;FontShow.class&quot; codebase=&quot;http://javacodespot.741.com/FontFormatter/&quot; height=&quot;150&quot; width=&quot;450&quot;&gt;&lt;/applet&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Georgia, serif; font-size: 13px; font-weight: 700; line-height: 20px;&quot;&gt;!!!!!!!!!!....Applet may take some time to load....!!!!!!!!!!&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt;&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Instruction:-&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;
1.) Select the type of font from the options in combo box.&lt;br /&gt;
2.) Select the size of font form the second combo box.&lt;br /&gt;
3.) Check or uncheck the Bold or Italic check box to change the style of font.&lt;br /&gt;
4.) Press Quit Button to Quit.&lt;br /&gt;
&lt;div align=&quot;center&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Available fonts:&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;
To get the available fonts list in&amp;nbsp;Java&amp;nbsp;a toolkit object is used. A&amp;nbsp;toolkit&amp;nbsp;object contains the list of the&amp;nbsp;available&amp;nbsp;fonts which can be fetched using a in build method.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse; font-size: 15px; line-height: 20px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-bottom-style: none; border-collapse: collapse; border-left-style: none; border-right-style: none; border-top-style: none; margin-left: 6.9pt; width: 600px;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 57.25pt;&quot;&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 1pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 1pt; border-top-color: windowtext; border-top-style: solid; border-top-width: 1pt; height: 57.25pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 517.55pt;&quot; valign=&quot;top&quot; width=&quot;600&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&amp;nbsp; &amp;nbsp;String[ ] &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fontList&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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-style-span&quot; style=&quot;color: blue;&quot;&gt;fontList&lt;/span&gt; = Toolkit.getDefaultToolkit().getFontList();&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;In this program a createFontChoice() function is written for making a combo box list of available fonts.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-bottom-style: none; border-collapse: collapse; border-left-style: none; border-right-style: none; border-top-style: none; font-family: &#39;Times New Roman&#39;; margin-left: 6.9pt; width: 600px;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 57.25pt;&quot;&gt;&lt;td style=&quot;border-bottom-color: windowtext; border-bottom-style: solid; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: solid; border-left-width: 1pt; border-right-color: windowtext; border-right-style: solid; border-right-width: 1pt; border-top-color: windowtext; border-top-style: solid; border-top-width: 1pt; height: 57.25pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 517.55pt;&quot; valign=&quot;top&quot; width=&quot;600&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;&lt;b&gt;private void&lt;/b&gt; &lt;/span&gt;createFontChoice() &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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-style-span&quot; style=&quot;color: blue;&quot;&gt;fontChoice&lt;/span&gt;.addItemListener(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;               &lt;/span&gt;String[] &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fontList&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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-style-span&quot; style=&quot;color: blue;&quot;&gt;fontList &lt;/span&gt;= Toolkit.getDefaultToolkit().getFontList();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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-style-span&quot; style=&quot;color: #660000;&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;int &lt;/span&gt;i=0; i&amp;lt;fontlist.length; i++)&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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-style-span&quot; style=&quot;color: blue;&quot;&gt;fontChoice&lt;/span&gt;.addItem(fontList[i]);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif; white-space: pre;&quot;&gt;            &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt; &amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp;fontName &lt;/span&gt;&lt;/span&gt;= fontList[0];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&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;color: #660000;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&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;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;color: #333333; font-family: Georgia, serif; font-size: 18px; font-weight: normal; line-height: 1.4em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0.25em; padding-bottom: 4px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative;&quot;&gt;Download Files Here:&lt;/h3&gt;&lt;ul style=&quot;color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 1.4; list-style-image: initial; list-style-position: initial; list-style-type: disc; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;&quot;&gt;&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-top-color: initial; border-top-style: none; border-width: initial; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;a href=&quot;http://javacodespot.110mb.com/FontFormatter.zip&quot; style=&quot;color: #336688; text-decoration: none;&quot; title=&quot;Source Code of Typing Test Application&quot;&gt;Download Source Code of Font Formatter JAVA Application (File Size: 5Kb)&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/7892113978306787296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2010/12/java-font-formatter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7892113978306787296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7892113978306787296'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2010/12/java-font-formatter.html' title='JAVA : Font Formatter'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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-5879038844944713475.post-7434773952940624507</id><published>2010-12-01T09:46:00.000-08:00</published><updated>2011-01-06T10:20:09.368-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA CODE SPOT : Painting Application"/><title type='text'>JAVA : Paint Application</title><content type='html'>&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;JAVA Paint Application&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;hr /&gt;&lt;b&gt;Java Paint application &lt;/b&gt;is a simple applet&amp;nbsp;implementation of&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;MS paint like application implemented in Java&amp;nbsp;written&amp;nbsp;by &lt;b&gt;Java Code Spot&lt;/b&gt; which allows user to draw different shapes and basic drawing.&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif; font-size: 14px;&quot;&gt;It has the basic drawing tools such as point, line, rectangles, round rectangles and circles and color manipulation options, other than that it has eraser tool. Paint application is a good example of how to use java&#39;s graphics libraries.&lt;/span&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizental link add */
google_ad_slot = &quot;3971116404&quot;;
google_ad_width = 728;
google_ad_height = 15;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot;&gt;&lt;applet border=&quot;1&quot; code=&quot;MainPage.class&quot; codebase=&quot;http://javacodespot.741.com/Paint/&quot; height=&quot;400&quot; width=&quot;500&quot;&gt;&lt;/applet&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Georgia, serif; font-size: 13px; font-weight: bold; line-height: 20px;&quot;&gt;!!!!!!!!!!....Applet may take some time to load....!!!!!!!!!!&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* first */
google_ad_slot = &quot;0978232117&quot;;
google_ad_width = 300;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-weight: bold; line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;b style=&quot;font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px;&quot;&gt;&lt;u&gt;Instruction:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;1)Select the drawing tool from the combo box.&lt;br /&gt;
2)Check draw or fill option to choose how to draw.&lt;br /&gt;
3)Check eraser option for using eraser tool.&lt;/span&gt;&lt;/span&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;color: #333333; font-weight: bold; line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;4)Choose color of drawing from color combo box.&lt;/span&gt;&lt;/span&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;color: #333333; font-weight: bold; line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;5)Press &#39;z&#39; for undo.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h3 style=&quot;color: #333333; font-family: Georgia, serif; font-size: 18px; font-weight: normal; line-height: 1.4em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0.25em; padding-bottom: 4px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;Download Files Here:&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 1.4; list-style-image: initial; list-style-position: initial; list-style-type: disc; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;&quot;&gt;&lt;li style=&quot;border-bottom-style: none; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-top-color: initial; border-top-style: none; border-width: initial; border-width: initial; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;a href=&quot;http://javacodespot.110mb.com/painting.zip&quot; style=&quot;color: #336688; text-decoration: none;&quot; title=&quot;Source Code of Typing Test Application&quot;&gt;Download Source Code of Paint JAVA Application (File Size: 9Kb)&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
google_ad_client = &quot;ca-pub-7948718914197429&quot;;
/* horizantel leaderbord */
google_ad_slot = &quot;5927722606&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt; &lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javacodespot.blogspot.com/feeds/7434773952940624507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javacodespot.blogspot.com/2010/12/java-paint-application.html#comment-form' title='20 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7434773952940624507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5879038844944713475/posts/default/7434773952940624507'/><link rel='alternate' type='text/html' href='http://javacodespot.blogspot.com/2010/12/java-paint-application.html' title='JAVA : Paint Application'/><author><name>Manoj Kumar Tiwari</name><uri>http://www.blogger.com/profile/08724671558021182351</uri><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>20</thr:total></entry></feed>