tag:blogger.com,1999:blog-50212095148422850782024-03-08T12:36:17.261-08:00Java By TrilochanJavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.comBlogger62125tag:blogger.com,1999:blog-5021209514842285078.post-45149548380833228232023-03-09T09:43:00.004-08:002023-03-09T09:43:35.499-08:00JAVA program to find the reverse of a string value and check whether the given string is palindrome or not ! <p> //JAVA program to find the reverse of a string value and check whether the given string is palindrome or not</p><p>import java.util.*;</p><p>class ReverseString</p><p>{</p><p><span style="white-space: pre;"> </span>public static void main(String[] args)</p><p><span style="white-space: pre;"> </span>{</p><p><span style="white-space: pre;"> </span>String str,rev="";</p><p><span style="white-space: pre;"> </span>int l;</p><p><br /></p><p><span style="white-space: pre;"> </span>Scanner s=new Scanner(System.in);</p><p><span style="white-space: pre;"> </span>System.out.println("enter the string value:");</p><p><span style="white-space: pre;"> </span>str=s.nextLine();</p><p><br /></p><p><span style="white-space: pre;"> </span>l=str.length();</p><p><span style="white-space: pre;"> </span>for(int i=l-1;i>=0;i--)</p><p><span style="white-space: pre;"> </span>{</p><p><span style="white-space: pre;"> </span>rev=rev+str.charAt(i);</p><p><span style="white-space: pre;"> </span>}<br /></p><p><br /></p><p><span style="white-space: pre;"> </span>System.out.println("The reverse is:"+rev);</p><p><br /></p><p><span style="white-space: pre;"> </span>if(str.equals(rev))</p><p><span style="white-space: pre;"> </span>{</p><p><span style="white-space: pre;"> </span>System.out.println("palindrome");</p><p><span style="white-space: pre;"> </span>}</p><p><span style="white-space: pre;"> </span>else</p><p><span style="white-space: pre;"> </span>{</p><p><span style="white-space: pre;"> </span>System.out.println("not palindrome");</p><p><span style="white-space: pre;"> </span>}</p><p><span style="white-space: pre;"> </span>}</p><p>}</p><p>Output : </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUarjMn9wKZ-52uqbXo5zz2Oezwy8VJZVSBmoSPQRGMpzMBfbDkWoqb54SKgnNL7Cg0QeHyZfcwhjeV2SkB9qTalZQXADJ_6FWfZRY1N7B9sxDk-BUwvi59WToPAmx3XQFZ6LfrE5L1SXVmSdCvZHcOKXRJzEE-na6qiT9QaCVxFlpQPDnam1KUNoxWA/s386/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="267" data-original-width="386" height="221" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUarjMn9wKZ-52uqbXo5zz2Oezwy8VJZVSBmoSPQRGMpzMBfbDkWoqb54SKgnNL7Cg0QeHyZfcwhjeV2SkB9qTalZQXADJ_6FWfZRY1N7B9sxDk-BUwvi59WToPAmx3XQFZ6LfrE5L1SXVmSdCvZHcOKXRJzEE-na6qiT9QaCVxFlpQPDnam1KUNoxWA/s320/1.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p></p>JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-2703882229524380342022-08-10T10:55:00.002-07:002022-08-10T10:55:50.425-07:00JAVA 8 Interview Question-2022 : What is Optional and why it is used ?<p> <b>Optional in JAVA 8:</b></p><p>Optional is a built in class present in java.util package also called as container class specifically used to represent optional values that exist or do not exist.</p><p>The main advantage is to avoid null. Here there is no NullPointerException will arise at the run time in the form of result.</p><p><br /></p><p>Note: For getting JAVA, Python, Machine Learning, Deep Learning tutorial in detail, follow:</p><p>www.pythontpoints.com</p><p><br /></p><p> -----------------------------Thank You----------------------------</p><p><br /></p><p><br /></p><p>Regards:</p><p>Trilochan Tarai | Associate Manager, Delivery, Majesco India </p><p>+91-9439202111</p>JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-58108945122877473972022-08-10T10:43:00.003-07:002022-08-10T10:43:29.244-07:00JAVA Interview Questions-2022 : JAVA 8 new Features !<p> <b>JAVA 8 newly Features:</b></p><p>1. Lambda Expression</p><p>2. Functional Interface</p><p>3. Method References</p><p>4. Stream API</p><p>5. Date Time API</p><p>6. Method References</p><p>7. Optional class present in java.util package</p><p>8. Nashorn : Highly improved JavaScript engine which enables the execution of JavaScript in JAVA.</p><p><br /></p><p> -------------Thank You----------------- </p><p><br /></p><p>Regards:</p><p>Trilochan Tarai | Associate Manager, Delivery, Majesco India</p><p>+91-9439202111</p>JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-83660053733102281892022-07-22T11:53:00.003-07:002022-07-27T12:04:14.396-07:00What is @RequestMapping Annotation in JAVA Spring? : JAVA Interview Question-2022<p> <b><span face=""Trebuchet MS", sans-serif" style="font-size: 13.5pt; line-height: 107%;">@RequestMapping Annotation:</span></b></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="background: white; font-size: 12pt;">This is one of the basic
annotations in Spring that maps HTTP requests with methods. This is used to map
the request into the specific method in Spring.</span><span face=""Trebuchet MS", sans-serif" style="font-size: 12pt;"><br /></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="font-size: 12pt;">
<span style="background: white;">The method is run every time an end-user makes
an </span></span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><a href="https://javarevisited.blogspot.com/2015/10/how-to-send-http-request-from-unix-or-linux-curl-wget-example.html" target="_blank"><span face=""Trebuchet MS",sans-serif" style="color: #0066cc;">HTTP
request</span></a></span><span face=""Trebuchet MS", sans-serif" style="background: white; font-size: 12pt;">. The mapping can also
be done at the method or class level.</span><span face=""Trebuchet MS", sans-serif" style="font-size: 12pt;"><br />
<br />
</span><span style="font-family: "Courier New"; font-size: 10pt;">@RequestMapping(</span><span style="font-family: "Courier New"; font-size: 10pt;">"/hello"</span><span style="font-family: "Courier New"; font-size: 10pt;">)</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><b><span style="font-family: "Courier New"; font-size: 10pt;">public</span></b><span style="font-family: "Courier New"; font-size: 10pt;"> <b>class</b> Hello</span><b><span style="font-family: "Courier New"; font-size: 10pt;">Controller</span></b><span style="font-family: "Courier New"; font-size: 10pt;">() </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span style="font-family: "Courier New"; font-size: 10pt;">{</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span style="font-family: "Courier New"; font-size: 10pt;"><span> <span> </span></span>@RequestMapping(</span><span style="font-family: "Courier New"; font-size: 10pt;">"/helloworld"</span><span style="font-family: "Courier New"; font-size: 10pt;">)</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><b><span style="font-family: "Courier New"; font-size: 10pt;"><span> </span><span> </span>public</span></b><span style="font-family: "Courier New"; font-size: 10pt;"> String show() </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span style="font-family: "Courier New"; font-size: 10pt;"><span> </span><span> </span>{</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-indent: 36pt;"><b><span style="font-family: "Courier New"; font-size: 10pt;"><span> </span><span> </span>return</span></b><span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="font-family: "Courier New"; font-size: 10pt;">"JAVA means Silan Software"</span><span style="font-family: "Courier New"; font-size: 10pt;">;</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span style="font-family: "Courier New"; font-size: 10pt;"><span> </span><span> </span>}</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span style="font-family: "Courier New"; font-size: 10pt;"><span> </span><span> </span>@RequestMapping(</span><span style="font-family: "Courier New"; font-size: 10pt;">"/helloall"</span><span style="font-family: "Courier New"; font-size: 10pt;">)</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><b><span style="font-family: "Courier New"; font-size: 10pt;"><span> </span><span> </span>public</span></b><span style="font-family: "Courier New"; font-size: 10pt;"> String display() </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span style="font-family: "Courier New"; font-size: 10pt;"><span> </span><span> </span>{</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm; text-indent: 36pt;"><b><span style="font-family: "Courier New"; font-size: 10pt;"><span> </span><span> </span>return</span></b><span style="font-family: "Courier New"; font-size: 10pt;"> </span><span style="font-family: "Courier New"; font-size: 10pt;">"javabytrilochan"</span><span style="font-family: "Courier New"; font-size: 10pt;">;</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span style="font-family: "Courier New"; font-size: 10pt;"><span> <span> </span></span>}</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span style="font-family: "Courier New"; font-size: 10pt;">}</span><span style="font-family: "Times New Roman",serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;">
<span face=""Trebuchet MS", sans-serif" style="font-size: 12pt; line-height: 107%;"><br />
<span style="background: white;">From here, the </span></span><span style="font-family: Courier; font-size: 12pt; line-height: 107%;">/hello</span><span face=""Trebuchet MS", sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> is assigned on the </span><span face=""Trebuchet MS", sans-serif" style="border: 1pt none windowtext; font-size: 12pt; line-height: 107%; padding: 0cm;">class level</span><span face=""Trebuchet MS", sans-serif" style="background: white; font-size: 12pt; line-height: 107%;">. And each method has
separate mappings and this allows to have a prefix before creating the mapping.</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="font-size: 12pt; line-height: 107%;"><br /></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="line-height: 107%;">Regards:</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="line-height: 107%;">Trilochan Tarai</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="line-height: 107%;">Associate Manager-Senior Lead Engineer,</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="line-height: 107%;">Majesco India</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="line-height: 107%;">+91-9439202111</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;"><span face=""Trebuchet MS", sans-serif" style="font-size: 12pt; line-height: 107%;">
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span></p>JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-52999491935108831632022-07-21T11:13:00.001-07:002022-07-21T11:33:54.053-07:00What is the difference between HashMap and Hashtable in JAVA ? : Mphasis JAVA Interview Question-2022<p> </p><p class="MsoNormal" style="line-height: 150%; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: medium;"><b>HashMap vs. Hashtable:</b></span></p><p class="MsoNormal" style="line-height: 150%; text-align: justify;"><span face=""Verdana",sans-serif" lang="EN-US" style="font-size: 12pt; line-height: 150%; mso-ansi-language: EN-US;">Both HashMap and Hashtable are two implementation
class of Map interface which contains pair. In a pair, one is key and one is
value.<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: 150%; text-align: justify;"><span face=""Verdana",sans-serif" lang="EN-US" style="font-size: 12pt; line-height: 150%; mso-ansi-language: EN-US;">There are many differences between HashMap and
Hashtable.<o:p></o:p></span></p>
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184;">
<tbody><tr style="height: 250.55pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;">
<td style="border: 1pt solid windowtext; height: 250.55pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 225.4pt;" valign="top" width="301">
<p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face=""Verdana",sans-serif" lang="EN-US" style="font-size: 12pt; line-height: 150%; mso-ansi-language: EN-US;"><span style="mso-spacerun: yes;"> </span><u>HashMap</u></span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" lang="EN-US" style="font-size: 12pt; line-height: 150%; text-indent: -18pt;"><span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><span face="Verdana, sans-serif" lang="EN-US" style="font-size: 12pt; line-height: 150%; text-indent: -18pt;">Introduced
in 1.2 version</span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">HashMap
is not synchronized, that means it is not in thread safe.</span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">HashMap
allows one null key and multiple null values.</span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">HashMap
is faster.</span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">We
can traverse HashMap by Iterator.</span></p>
</td>
<td style="border-left: none; border: 1pt solid windowtext; height: 250.55pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 225.4pt;" valign="top" width="301">
<p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face=""Verdana",sans-serif" lang="EN-US" style="font-size: 12pt; line-height: 150%; mso-ansi-language: EN-US;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><u>Hashtable<o:p></o:p></u></span></p>
<p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">Introduced
in 1.0 version, that’s why it is called as legacy.</span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">Hashtable
is synchronized, that means it is thread safe.</span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">Hashtable
not allowed any null key or value.</span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">Hashtable
is slow.</span></p><p class="MsoNormal" style="line-height: 150%; margin-bottom: 0cm; text-align: justify;"><span face="Verdana, sans-serif" style="font-size: 12pt; text-indent: -18pt;">We
can traverse Hashtable by Enumerator and Iterator.</span></p>
</td>
</tr>
</tbody></table><br /><div><br /></div><div>Our Services:</div><div>JAVA Training || JAVA Projects || JAVA Internship || JAVA Placements || Python Training || AI & Machine Learning with Python Training || Data Science Training</div><div>Call to : 0674-2361252</div>JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com1tag:blogger.com,1999:blog-5021209514842285078.post-50739749413960663452022-07-20T11:41:00.000-07:002022-07-20T11:41:17.207-07:00What is Predicate in JAVA 8 ? Mphasis Interview Question-2022<p> <span style="font-family: inherit; font-size: medium;">Predicate in JAVA 8:</span></p><p style="text-align: justify;"><span style="font-size: medium;">A predicate is a built in functional interface present in <b>java.util.function </b>package. It is specifically used for code management and unit testing. It contains many built in methods which is as follows:</span></p><p style="text-align: justify;"><span style="font-size: medium;"><b>test(T t): </b></span><span style="background-color: white; color: #3d3d4e; font-family: "Droid Serif", Georgia, serif; font-size: 18px; text-align: left;">It evaluates the predicate on the value passed to this function as the argument and returning a boolean value(true / false).</span></p><p style="text-align: justify;"><span style="font-size: medium;"><b><u>TestExample.java</u></b></span></p><p style="text-align: justify;"><span style="font-size: medium;">import java.util.function.Predicate; </span></p><p style="text-align: justify;"><span style="font-size: medium;"><br /></span></p><p style="text-align: justify;"><span style="font-size: medium;">class TestExample</span></p><p style="text-align: justify;"><span style="font-size: medium;">{</span></p><p style="text-align: justify;"><span style="font-size: medium;"><span style="white-space: pre;"> </span>public static void main(String[] args)</span></p><p style="text-align: justify;"><span style="font-size: medium;"><span style="white-space: pre;"> </span>{</span></p><p style="text-align: justify;"><span style="font-size: medium;"><span style="white-space: pre;"> </span>Predicate<Integer> greater_than = x -> (x > 100); </span></p><p style="text-align: justify;"><span style="font-size: medium;"> </span></p><p style="text-align: justify;"><span style="font-size: medium;"> // calling test method of the predicate</span></p><p style="text-align: justify;"><span style="font-size: medium;"> System.out.println(greater_than.test(200)); </span></p><p style="text-align: justify;"><span style="font-size: medium;"> } </span></p><p style="text-align: justify;"></p><p style="text-align: justify;"><span style="font-size: medium;">} </span></p><p style="text-align: justify;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKU0HapYdL2NUd7QppWuibtnPI82ygnl3H0oSIQQYo5WhvbWlCSbA8JhzfjT0chV2K8b3YZIG3zeGW5s6MTrdsd6D00gQAAfVelYebJovlooU9YysS-y8s8JKumhr2Pk4P2MTvURF1cHxJDBJNw-qMBwR8zKxT80-YivgFNCo7-PCbBRoL8q6thNouqw/s375/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="137" data-original-width="375" height="117" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKU0HapYdL2NUd7QppWuibtnPI82ygnl3H0oSIQQYo5WhvbWlCSbA8JhzfjT0chV2K8b3YZIG3zeGW5s6MTrdsd6D00gQAAfVelYebJovlooU9YysS-y8s8JKumhr2Pk4P2MTvURF1cHxJDBJNw-qMBwR8zKxT80-YivgFNCo7-PCbBRoL8q6thNouqw/s320/1.png" width="320" /></a></div><br /><span style="font-size: medium;"><br /></span><p></p>JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-35487386064947700582020-04-02T10:06:00.002-07:002022-07-21T11:31:38.086-07:00What is dependency injection in JAVA spring framework ?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Spring is an open source, light weight, and non-invasive framework which is specifically used to develop web and enterprise application. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Dependency Injection is a process where the spring framework injecting dependency to a dependent object.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Dependency Injection is a software design pattern that implements inversion of control for resolving dependencies.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Our Services:</div>
<div style="text-align: justify;">
JAVA training || JAVA projects || JAVA Internship || Python training || AI & Machine Learning training || Data Science training</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Call us: 0674-2361252</div>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-44429356800713333162019-07-23T10:36:00.000-07:002019-07-23T10:46:12.161-07:00How to kill a thread in JAVA ??<div dir="ltr" style="text-align: left;" trbidi="on">
Ans:<br />
<br />
<div class="MsoNormal">
<span style="background: white; color: #242729; font-family: "arial" , "sans-serif"; font-size: 11.5pt; line-height: 115%;">'Killing a thread' is not
the right phrase to use. Here is one way we can implement graceful exit of the
thread:<o:p></o:p></span></div>
class TaskThread implements Runnable {<br />
<br />
boolean shouldStop;<br />
<br />
public TaskThread(boolean shouldStop) {<br />
this.shouldStop = shouldStop;<br />
}<br />
<br />
@Override<br />
public void run() {<br />
<br />
System.out.println("Thread has started");<br />
<br />
while (!shouldStop) {<br />
// do something<br />
}<br />
<br />
System.out.println("Thread has ended");<br />
<br />
}<br />
public void stop() {<br />
shouldStop = true;<br />
}<br />
<br />
<br />
}<br />
public class ThreadStop<br />
{<br />
<span style="white-space: pre;"> </span>public static void main(String[] args)<br />
<span style="white-space: pre;"> </span>{<br />
<span style="white-space: pre;"> </span>System.out.println("Start");<br />
<br />
<span style="white-space: pre;"> </span>// Start the thread<br />
<span style="white-space: pre;"> </span>TaskThread task = new TaskThread(false);<br />
<span style="white-space: pre;"> </span>Thread t = new Thread(task);<br />
<span style="white-space: pre;"> </span>t.start();<br />
<br />
<span style="white-space: pre;"> </span>// Stop the thread<br />
<span style="white-space: pre;"> </span>task.stop();<br />
<br />
<span style="white-space: pre;"> </span>System.out.println("End");<br />
<br />
<span style="white-space: pre;"> </span>}<br />
}<br />
<br /></div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-57348836220718565102019-07-05T03:20:00.000-07:002019-07-05T03:20:01.673-07:00JAVA StringBuffer and StringBuilder object conversion to String<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="background: white; line-height: 150%; margin-bottom: .0001pt; margin: 0in; text-align: justify; vertical-align: baseline;">
<span style="color: #444444; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: Arial;">We can convert a StringBuffer or StringBuilder object<span style="mso-spacerun: yes;"> </span>to String by using toString() method of
Object class.<o:p></o:p></span></div>
<div class="MsoNormal">
<u><span style="font-family: "Verdana","sans-serif";">StringConversion.java<o:p></o:p></span></u></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">class
StringConversion<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 1;"> </span>public static void main(String[] args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>StringBuffer sb1=new
StringBuffer("Silan");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>StringBuilder sb2=new
StringBuilder("Technology");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>String s1=sb1.toString();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>String s2=sb2.toString();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>System.out.println(s1+"
"+s2);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">}<o:p></o:p></span></div>
Output:<br />
Silan Technology<br />
<br />
<br />
<div class="MsoNormal">
<u><span style="font-family: "Verdana","sans-serif";">StringConversion1.java<o:p></o:p></span></u></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">class
StringConversion1<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 1;"> </span>public static void main(String[] args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 1;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>StringBuffer sb1=new
StringBuffer("Silan");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>StringBuffer sb2=new
StringBuffer("Silan");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>String s1=sb1.toString();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>String s2=sb2.toString();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>if(s1.equals(s2))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 3;"> </span>System.out.println("s1
and s2 contents are equal");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>else<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 3;"> </span>System.out.println("s1
and s2 contents are not equal");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 2;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><span style="mso-tab-count: 1;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">}<o:p></o:p></span></div>
Output:<br />
s1 and s2 contents are equal</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-13425178525693419562019-02-09T03:35:00.000-08:002019-02-09T03:35:08.024-08:00JAVA : How to generate OTP<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><u><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">OtpExample.java<o:p></o:p></span></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">package</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> java8s;</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">import</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> java.util.*;</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">public</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">class</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> OtpExample {</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 1;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 1;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">static</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">char</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">[] show(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">int</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">len</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">) </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>{<span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>System.</span><b><i><span style="color: #0000c0; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">out</span></i></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.print(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">"Your OTP is : "</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">); </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>String </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">numbers</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><span style="color: #2a00ff; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">"0123456789"</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>Random </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">rd</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">new</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> Random(); </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">char</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">[] </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">otp</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">new</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">char</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">[</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">len</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">]; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">for</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> (</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">int</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">i</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = 0; </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">i</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> < </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">len</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">i</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">++) </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>{ </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">otp</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">[</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">i</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">] = </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">numbers</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.charAt(</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">rd</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.nextInt(</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">numbers</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.length())); </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>} </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">return</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">otp</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>} </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 1;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">public</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">static</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">void</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> main(String[] </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">args</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">) {</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 2;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 2;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">int</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">length</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = 5; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>System.</span><b><i><span style="color: #0000c0; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">out</span></i></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.println(<i>show</i>(</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">length</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">));</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 1;"> </span>}</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">}</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas;">Output:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-bidi-font-family: Consolas;">Your OTP is : 35838</span><span style="font-family: "Verdana","sans-serif";"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-bidi-font-family: Consolas;"><br /></span></div>
<div class="MsoNormal">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-bidi-font-family: Consolas;">Thanks & Regards:</span></div>
<div class="MsoNormal">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-bidi-font-family: Consolas;">Trilochan Tarai</span></div>
<div class="MsoNormal">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-bidi-font-family: Consolas;">SILAN Technology & java8s.com</span></div>
<div class="MsoNormal">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; line-height: 115%; mso-bidi-font-family: Consolas;">+91-9658317757</span></div>
<br /></div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-32150649149635671882019-02-09T03:32:00.001-08:002019-02-09T03:32:16.694-08:00JAVA : How to generate password<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: #3f7f5f; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">//JAVA
source code to generate random password</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><u><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">PasswordExample.java<o:p></o:p></span></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">package</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> java8s;</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">import</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> java.util.*;</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">public</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">class</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> PasswordExample {</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 1;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">public</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">static</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">void</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> main(String[] </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">args</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">) {</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 2;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 2;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">int</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">length</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = 10; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>System.</span><b><i><span style="color: #0000c0; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">out</span></i></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.println(<i>silanPassword</i>(</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">length</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">)); </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 2;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 1;"> </span>}</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 1;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-tab-count: 1;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">static</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">char</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">[] silanPassword(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">int</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">len</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">) </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>{ </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>System.</span><b><i><span style="color: #0000c0; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">out</span></i></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.print(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">"Your new password is : "</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">); </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>String </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">uchars</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><span style="color: #2a00ff; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>String </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">lchars</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><span style="color: #2a00ff; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">"abcdefghijklmnopqrstuvwxyz"</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>String </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">numbers</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><span style="color: #2a00ff; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">"0123456789"</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>String </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">symbols</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><span style="color: #2a00ff; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">"!@#$%^&*_=+-/.?<>)"</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>String </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">values</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">uchars</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> + </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">lchars</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> + </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">numbers</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> + </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">symbols</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>Random </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">rd</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">new</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> Random(); </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">char</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">[] </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">password</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">new</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">char</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">[</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">len</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">]; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">for</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> (</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">int</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">i</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> = 0; </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">i</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> < </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">len</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">i</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">++) </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>{ </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">password</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">[</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">i</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">] = </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">values</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.charAt(</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">rd</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.nextInt(</span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">values</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">.length())); </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>} </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">return</span></b><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"> </span><span style="color: #6a3e3e; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">password</span><span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">; </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>} </span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">}</span><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;">Output:</b><span style="font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 12.0pt; mso-bidi-font-family: Consolas;">Your new
password is : mR!XPdfVmg<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-align: justify; text-autospace: none;">
<strong><span style="background: white; border: none windowtext 1.0pt; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: Arial; mso-border-alt: none windowtext 0in; padding: 0in;">Note : </span></strong><strong><span style="background: white; border: none windowtext 1.0pt; font-family: "Verdana","sans-serif"; font-size: 10.0pt; font-weight: normal; line-height: 150%; mso-bidi-font-family: Arial; mso-bidi-font-weight: bold; mso-border-alt: none windowtext 0in; padding: 0in;">Here
we have used random() to generate the password. It may change every time due to
use of random() method.</span></strong><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: Consolas;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify;">
<br /></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><o:p><strong style="font-family: "Times New Roman"; font-size: medium;"><span style="background: white; border: 1pt none windowtext; font-family: Verdana, sans-serif; font-size: 10pt; font-weight: normal; line-height: 20px; padding: 0in;">Thanks & Regards:'</span></strong></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><o:p><strong style="font-family: "Times New Roman"; font-size: medium;"><span style="background: white; border: 1pt none windowtext; font-family: Verdana, sans-serif; font-size: 10pt; font-weight: normal; line-height: 20px; padding: 0in;">Trilochan Tarai</span></strong></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><o:p><strong style="font-family: "Times New Roman"; font-size: medium;"><span style="background: white; border: 1pt none windowtext; font-family: Verdana, sans-serif; font-size: 10pt; font-weight: normal; line-height: 20px; padding: 0in;">SILAN Technology & java8s.com</span></strong></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><o:p><strong style="font-family: "Times New Roman"; font-size: medium;"><span style="background: white; border: 1pt none windowtext; font-family: Verdana, sans-serif; font-size: 10pt; font-weight: normal; line-height: 20px; padding: 0in;">0674-2361252</span></strong></o:p></span></div>
<br /></div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-36334895874159764252018-12-17T02:29:00.003-08:002018-12-17T02:29:56.308-08:00JAVA ArrayList Constructors<div dir="ltr" style="text-align: left;" trbidi="on">
<b>JAVA ArrayList Constructors</b><br />
<br />
<br />
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html" title="class in java.lang"><span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; text-decoration: none; text-underline: none;">java.lang.Object</span></a><span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><span style="mso-spacerun: yes;"> </span></span><a href="https://docs.oracle.com/javase/8/docs/api/java/util/AbstractCollection.html" title="class in java.util"><span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; text-decoration: none; text-underline: none;">java.util.AbstractCollection</span></a><span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><span style="mso-spacerun: yes;"> </span></span><a href="https://docs.oracle.com/javase/8/docs/api/java/util/AbstractList.html" title="class in java.util"><span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; text-decoration: none; text-underline: none;">java.util.AbstractList</span></a><span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Arial","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>java.util.ArrayList<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">public class <b>ArrayList</b><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">extends </span><a href="https://docs.oracle.com/javase/8/docs/api/java/util/AbstractList.html" title="class in java.util"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; text-decoration: none; text-underline: none;">AbstractList</span></a><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">implements </span><a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html" title="interface in java.util"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; text-decoration: none; text-underline: none;">List</span></a><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">, </span><a href="https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html" title="interface in java.util"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; text-decoration: none; text-underline: none;">RandomAccess</span></a><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">, </span><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Cloneable.html" title="interface in java.lang"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; text-decoration: none; text-underline: none;">Cloneable</span></a><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">, </span><a href="https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html" title="interface in java.io"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; text-decoration: none; text-underline: none;">Serializable</span></a><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><o:p></o:p></span></div>
<div class="MsoListParagraph" style="line-height: 150%; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana; mso-themecolor: text1;"><span style="mso-list: Ignore;">1.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">ArrayList()</span></b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"> : </span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">Create an empty ArrayList object with default
initial capacity 10. Once ArrayList reaches its max capacity then new ArrayList
will be created with a new capacity.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%;">
<span style="background: white; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">new capacity=(current capacity*3/2)+1</span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><br />
<span style="background: white;">i.e (10*3/2)+1=16 </span><br />
<span style="background: white;">after this new ArrayList is created the previous
one will be deleted and it will be treated as garbage.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 150%;">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana; mso-themecolor: text1;"><span style="mso-list: Ignore;">2.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">ArrayList(int initialcapacity)</span></b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"> : </span><span style="background: white; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-themecolor: text1;">Constructs an empty ArrayList with the specified
initial capacity given by the user.</span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: 150%; mso-add-space: auto; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-align: justify; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana; mso-themecolor: text1;"><span style="mso-list: Ignore;">3.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: Arial; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">ArrayList(Collection c)</span></b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: Arial; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"> : For every Collection object, we can create
an equivalent ArrayList.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: Arial; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;">ArrayListExample1.java<o:p></o:p></span></u></b></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="background: white; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">importjava.util.*;</span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><br />
<span style="background: white;">classArrayListExample1</span><br />
<span style="background: white;">{</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;"> </span>public
static void main(String[] args)</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;"> </span>{</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>ArrayList al=new ArrayList();</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>al.add("Sashi");</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>al.add("Satyajit");</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>al.add(20);</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>al.add(null);</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>System.out.println(al); <span style="mso-spacerun: yes;"> </span>//[Sashi,Satyajit,20,null]</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>al.remove(1);</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>al.add(1,"Sasmita");</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>al.add("Nilan");</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;">
</span>System.out.println(al); <span style="mso-spacerun: yes;"> </span>//[Sashi,Sasmita,20,null,Nilan]</span><br />
<span style="background: white;"><span style="mso-spacerun: yes;"> </span>}</span><br />
<span style="background: white;">}<o:p></o:p></span></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<b style="mso-bidi-font-weight: normal;"><span style="background: white; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">Output<o:p></o:p></span></b></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="background: white; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">[Sashi,Satyajit,20,null]<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="background: white; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">[Sashi,Sasmita,20,null,Nilan]</span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><br style="mso-special-character: line-break;" />
<!--[if !supportLineBreakNewLine]--><br style="mso-special-character: line-break;" />
<!--[endif]--><span style="background: white;"><o:p></o:p></span></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><b>Thanks & Regards:</b></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">Trilochan Tarai</span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">SILAN Technology</span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">java8s.com</span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">0674-2361252</span></div>
<br /></div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-10967936758798951342018-11-07T04:11:00.001-08:002018-11-07T04:11:54.681-08:00Difference between JAVA Collection & Collections<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="line-height: 200%; text-align: justify;">
<span style="background: white; color: #242729; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-bidi-font-family: Arial;">Collection is a root
level interface of the Java Collection Framework. Most of the classes in Java
Collection Framework implements from this interface. List, Set and Queue are
main sub interfaces of this interface. JDK doesn’t provide any direct
implementations of this interface. But, JDK provides direct implementations of
it’s sub interfaces. ArrayList, Vector, HashSet, LinkedHashSet, PriorityQueue
are some indirect implementations of Collection interface. Map interface, which
is also a part of java collection framework, doesn’t inherit from Collection
interface. Collection interface is a member of java.util package.</span><o:p></o:p></div>
<div class="MsoNormal" style="line-height: 200%; text-align: justify;">
<span style="background: white; color: #242729; font-family: "Arial","sans-serif"; font-size: 11.5pt; line-height: 200%;">Collections is an utility class in java.util
package. It consists of only static methods which are used to operate on
objects of type Collection. For example, it has the method to find the maximum
element in a collection, it has the method to sort the collection, it has the
method to search for a particular element in a collection. Below is the list of
some important methods of Collections class.</span><o:p></o:p></div>
<div class="MsoNormal" style="background: #EFF0F1; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify; vertical-align: baseline;">
<span style="background: #EFF0F1; border: none windowtext 1.0pt; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; padding: 0in;">Collections.max()<o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EFF0F1; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify; vertical-align: baseline;">
<span style="background: #EFF0F1; border: none windowtext 1.0pt; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; padding: 0in;">Collections.min()<o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EFF0F1; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify; vertical-align: baseline;">
<span style="background: #EFF0F1; border: none windowtext 1.0pt; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; padding: 0in;">Collections.sort()<o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EFF0F1; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-align: justify; vertical-align: baseline;">
<span style="background: #EFF0F1; border: none windowtext 1.0pt; color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1; padding: 0in;">Collections.synchronizedCollection()</span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-fareast-font-family: "Times New Roman"; mso-themecolor: text1;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify;">
<br /></div>
<br /><br />
Thanks & Regards:<br />
Trilochan Tarai<br />
9439202111</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-70231192058501841652018-10-11T08:43:00.000-07:002018-10-11T08:43:16.074-07:00JAVA 11 Features<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Some JAVA 11 Features</b><br />
<b><br /></b>
<br />
<div class="MsoNormal" style="line-height: 200%;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-themecolor: text1;"><span style="color: black;">1. Nest-Based Access Control</span><br style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;" /><span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;"><span style="color: black;">2. Dynamic Class-File Constants</span></span><br style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;" />
<span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;"><span style="color: black;">3. Epsilon: A No-Op Garbage Collector</span></span><br style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;" />
<span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;"><span style="color: black;">4. Remove the JAVA EE and CORBA Modules</span></span><br style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;" />
<span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;"><span style="color: black;">5. HTTP Client(Standard)</span></span><br style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;" />
<span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;"><span style="color: black;">6. Local-Variable Syntax for Lambda Parameters</span></span><br style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;" />
<span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;"><span style="color: black;">7. Unicode 10</span></span><br style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;" />
<span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;"><span style="color: black;">8. Flight Recorder</span></span><br style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; widows: 2; word-spacing: 0px;" /><br /><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 200%;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-themecolor: text1;"><br /></span></div>
<div class="MsoNormal" style="line-height: 200%;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-themecolor: text1;">Thanks & Regards:</span></div>
<div class="MsoNormal" style="line-height: 200%;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-themecolor: text1;">Trilochan Tarai</span></div>
<div class="MsoNormal" style="line-height: 200%;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-themecolor: text1;">SILAN Technology & java8s.com</span></div>
<div class="MsoNormal" style="line-height: 200%;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-themecolor: text1;">+91-9439202111</span></div>
<div class="MsoNormal" style="line-height: 200%;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-themecolor: text1;">0674-2361252</span></div>
<div class="MsoNormal" style="line-height: 200%;">
<span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 200%; mso-themecolor: text1;"><br /></span></div>
<b></b></div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-34945002068463960952018-08-21T23:47:00.001-07:002018-08-21T23:47:45.667-07:00Why JAVA is Object-Oriented ???<div dir="ltr" style="text-align: left;" trbidi="on">
Why JAVA is OO(Object-Oriented) ??<br />
<br />
A Java Program is nothing but a class or more than one class. Everything we will write inside a class. That concept is Object Oriented.<br />
<br />
Another fact is Object Oriented Features are supporting like Class, Object, Data Abstraction & Encapsulation, Inheritance, Polymerphism, Dynamic Binding, Message Passing etc.<br />
<br />
Another important point is when a method is invoking by an object then the method definition is executing. This is object oriented concept, JAVA is supporting.<br />
<br />
<br />
<br />
<br />
Thanks & Regards:<br />
Trilochan Tarai<br />
JAVA Expert<br />
SILAN Technology & java8s.com<br />
trilochan@silantechnology.com<br />
9439202111<br />
<br /></div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-24112474754092171922018-08-21T23:29:00.001-07:002018-08-21T23:29:29.137-07:00What is JAVA ???<div dir="ltr" style="text-align: left;" trbidi="on">
1. JAVA is a general purpose high level programming language.<br />
<br />
2. JAVA is a technology.<br />
<br />
3. JAVA is an OOP(Object Oriented Programming) Language.<br />
<br />
4. JAVA is a platform.<br />
<br />
<br />
Note : JAVA is itself a platform because JAVA having its own JRE(JAVA Run-time Environment).<br />
<br />
<br />
<br />
Thanks & Regards:<br />
Trilochan Tarai<br />
JAVA Expert<br />
SILAN Technology & java8s.com<br />
9439202111</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-52868787636293996242018-08-12T06:21:00.002-07:002018-08-12T06:21:40.362-07:00Why can't i use static variable in java constructor?<div dir="ltr" style="text-align: left;" trbidi="on">
Example:<br />
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px;">
class Student{</div>
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;">
Student() {<br />static int i = 0;<br />System.out.println(i++); <span class="text_exposed_show" style="display: inline; font-family: inherit;"><br />}<br />public static void main(String args[]){<br />Student s1 = new Student();<br />Student s2 = new Student();<br />Student s3 = new Student();<br />}<br />} </span></div>
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;">
<span class="text_exposed_show" style="display: inline; font-family: inherit;"><br /></span></div>
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;">
<span class="text_exposed_show" style="display: inline; font-family: inherit;">Here, Why can't i use static variable in java constructor?</span></div>
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;">
<span class="text_exposed_show" style="display: inline; font-family: inherit;"><br /></span></div>
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;">
<span class="text_exposed_show" style="display: inline; font-family: inherit;">Ans:</span></div>
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;">
<span class="text_exposed_show" style="display: inline; font-family: inherit;">If you want to declare static variable then declare it outside of the constructor, at class level like this -</span></div>
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;">
<span class="text_exposed_show" style="display: inline; font-family: inherit;"></span></div>
<div class="text_exposed_show" style="background-color: white; color: #1d2129; display: inline; font-family: Helvetica, Arial, sans-serif; font-size: 14px;">
<div style="font-family: inherit; margin-bottom: 6px;">
public class Student{</div>
<div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;">
private static int i;</div>
<div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;">
}<br />You declaration of static occurred at your constructor which is a local variable and local variable can not be static. And that's why you are getting - illegal modifier for parameter i. And finally for initializing static variable you may use a static initialization block (though it's not mandatory) -</div>
<div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;">
public class Student{</div>
<div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;">
private static int i;</div>
<div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;">
static {<br />i = 5;<br />}</div>
<div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;">
}</div>
</div>
<div style="background-color: white; color: #1d2129; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;">
<span class="text_exposed_show" style="display: inline; font-family: inherit;"><br /></span></div>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-41826203687682126502018-08-07T02:35:00.000-07:002018-08-07T02:35:13.442-07:00JAVA 10 exciting Feature : Local Variable Type Inference <div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";"><b>JAVA 10 : Local Variable Type Inference</b></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">Like JavaScript, Kotlin,
and Scala, now Java 10 introduced <b>var</b>
keyword that allows you to declare a local variable without specifying its
type. The type will be inferred from context. For example, when you say </span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">var name = "Silan"</span><span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">, then
the compiler will already know the type is String.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">The var keyword can only
be used for local variables, i.e. variables inside methods or code blocks — you
cannot use it for member variable declaration inside the class body.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">But like Python, it
doesn't make Java a dynamically typed language. Java is still a statically
typed language, and once the type is assigned, you cannot change it. For
example, </span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">var name = "Silan"</span><span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";"> is ok, but if we will assign </span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">name =100;</span><span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";"> then it is not
right.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">This is one of the most
eye-catching features of Java 10. It reduces the amount of boilerplate code
needed to declare local variables in Java.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">Overall we can say in a
single statement that we can declare variables without specifying the
associated type. A declaration such as:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">List<String> l=new
ArrayList<String>();<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">Can be written as var
l=new ArrayList<String>();<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: 11.25pt; margin-left: 0in; margin-right: 0in; margin-top: 3.75pt; text-align: justify; text-justify: inter-ideograph;">
<b><span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">Note</span></b><span style="color: #222635; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">: Type Inference is not a
new Concept in JAVA but it is a new concept for local variables. <o:p></o:p></span></div>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com1tag:blogger.com,1999:blog-5021209514842285078.post-28267625685356975292018-07-03T09:41:00.002-07:002018-07-03T09:41:38.638-07:00Conversion from String to StringBuffer and StringBuilder <div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 30.85pt; margin-right: 0in; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-align: justify; text-indent: -.25in; text-justify: inter-ideograph; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif;"> Here in this context We can
directly pass String class object to StringBuffer and StringBuilder class
constructors. As String class is immutable in java, so for editing a string, we
can perform same by converting it to StringBuffer or StringBuilder class
objects. </span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 30.85pt; margin-right: 0in; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-align: justify; text-indent: -.25in; text-justify: inter-ideograph; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; text-indent: -0.25in;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 30.85pt; margin-right: 0in; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-align: justify; text-indent: -.25in; text-justify: inter-ideograph; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; text-indent: -0.25in;"><u>Example.java</u></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">package</span></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> java8s;</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">public</span></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><b><span style="color: #7f0055; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">class</span></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> Example {</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><b><span style="color: #7f0055; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">public</span></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><b><span style="color: #7f0055; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">static</span></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><b><span style="color: #7f0055; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">void</span></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> main(String[] </span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">args</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">) {</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> String
</span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">str</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">=</span><span style="color: #2a00ff; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">"SILAN"</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">;</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="color: #3f7f5f; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">//Conversion from String
object to StringBuffer</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> StringBuffer
</span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">sb1</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">=</span><b><span style="color: #7f0055; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">new</span></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> StringBuffer(</span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">str</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">);</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> System.</span><b><i><span style="color: #0000c0; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">out</span></i></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">.println(</span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">sb1</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">);</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">sb1</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">.reverse();</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> System.</span><b><i><span style="color: #0000c0; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">out</span></i></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">.println(</span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">sb1</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">);</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="color: #3f7f5f; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">//Conversion from String
object to Str<span style="background: silver; mso-highlight: silver;">ingBuilder</span></span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: silver; font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> StringBu<span style="background: silver; mso-highlight: silver;">ilder </span></span><span style="background: silver; color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-highlight: silver;">sb2</span><span style="background: silver; font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">=</span><b><span style="background: silver; color: #7f0055; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New"; mso-highlight: silver;">new</span></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> StringBuilder(</span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">str</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">);</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">sb2</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">.append(</span><span style="color: #2a00ff; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">"Technology"</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">);</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> System.</span><b><i><span style="color: #0000c0; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">out</span></i></b><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">.println(</span><span style="color: #6a3e3e; font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";">sb2</span><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">);</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> </span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"> }</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%; mso-bidi-font-family: "Courier New";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 30.85pt; margin-right: 0in; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-align: justify; text-indent: -.25in; text-justify: inter-ideograph; vertical-align: baseline;">
</div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">Output:</span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">SILAN </span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">NALIS</span></div>
<div class="MsoNormal" style="background: white; line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 150%;">SILANTechnology</span></div>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com1tag:blogger.com,1999:blog-5021209514842285078.post-52343084312483692942018-06-28T07:16:00.002-07:002018-06-28T07:16:46.121-07:00Why main() in JAVA is public !!<div dir="ltr" style="text-align: left;" trbidi="on">
Answer :<br />
main() in JAVA is public due to the following two reasons:<br />
<br />
1. main() method can be accessed by any no. of classes.<br />
2. main() method can be invoked by JVM from everywhere.<br />
<br />
<br />
Note: The keyword public is a modifier.</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-61079945428765447862018-03-26T23:36:00.001-07:002018-03-26T23:36:05.599-07:00Does finally always execute in Java?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
Yes, <code style="background-color: #eff0f1; border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">finally</code> will be called.</div>
<div style="background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
The only times <code style="background-color: #eff0f1; border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">finally</code> won't be called are:</div>
<ol style="background-color: white; border: 0px; box-sizing: inherit; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1em 30px; padding: 0px; vertical-align: baseline;">
<li style="border: 0px; box-sizing: inherit; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px 0px 0.5em; padding: 0px; vertical-align: baseline; word-wrap: break-word;">If you invoke <code style="background-color: #eff0f1; border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">System.exit()</code>;</li>
<li style="border: 0px; box-sizing: inherit; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px 0px 0.5em; padding: 0px; vertical-align: baseline; word-wrap: break-word;">If the JVM crashes first;</li>
<li style="border: 0px; box-sizing: inherit; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px 0px 0.5em; padding: 0px; vertical-align: baseline; word-wrap: break-word;">If there is an infinite loop (or some other non-interruptable, non-terminating statement) in the <code style="background-color: #eff0f1; border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">try</code> block;</li>
<li style="border: 0px; box-sizing: inherit; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px 0px 0.5em; padding: 0px; vertical-align: baseline; word-wrap: break-word;">If the OS forcibly terminates the JVM process.</li>
<li style="border: 0px; box-sizing: inherit; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">If the host system dies; e.g. power failure, hardware error, etc.</li>
</ol>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-31100779830596386202018-03-26T23:33:00.002-07:002018-03-26T23:33:24.478-07:00Is Java “pass-by-reference” or “pass-by-value”?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px;">Java is always </span><strong style="background-color: white; border: 0px; box-sizing: inherit; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">pass-by-value</strong><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px;">. Unfortunately, they decided to call the location of an object a "reference". When we pass the value of an object, we are passing the </span><em style="background-color: white; border: 0px; box-sizing: inherit; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">reference</em><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px;"> to it. This is confusing to beginners.</span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px;">Example;</span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px;"><br /></span></div>
<pre class="lang-java prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">public</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">static</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">void</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> main</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">String</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">[]</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> args </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Dog</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> aDog </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Dog</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Max"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">// we pass the object to foo</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
foo</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">aDog</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">// aDog variable is still pointing to the "Max" dog when foo(...) returns</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
aDog</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">getName</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">().</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">equals</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Max"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">// true, java passes by value</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
aDog</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">getName</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">().</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">equals</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Fifi"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">// false </span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">}</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">public</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">static</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">void</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> foo</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Dog</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> d</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
d</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">getName</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">().</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">equals</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Max"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">// true</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">// change d inside of foo() to point to a new Dog instance "Fifi"</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
d </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">Dog</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Fifi"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
d</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">getName</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">().</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">equals</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Fifi"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="com" style="border: 0px; box-sizing: inherit; color: #858c93; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">// true</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">}</span></code></pre>
<pre class="lang-java prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; text-align: justify; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">In this <a href="http://ideone.com/oUEPbg" rel="noreferrer" style="background-color: white; border: 0px; box-sizing: inherit; color: #005999; cursor: pointer; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline; white-space: normal;">example</a><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">aDog.getName()</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> will still return </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">"Max"</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;">. The value </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">aDog</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> within </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">main</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> is not changed in the function </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">foo</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> with the </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">Dog</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">"Fifi"</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> as the object reference is passed by value. If it were passed by reference, then the </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">aDog.getName()</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> in </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">main</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> would return </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">"Fifi"</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;"> after the call to </span><code style="border: 0px; box-sizing: inherit; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 1px 5px; vertical-align: baseline; white-space: pre-wrap;">foo</code><span style="background-color: white; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; white-space: normal;">.</span></span></code></pre>
<pre class="lang-java prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span></code></pre>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-80477541789145659042018-03-26T23:28:00.004-07:002018-03-26T23:28:37.972-07:00Can main() method overloaded ??<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">Yes, main()
can be overloaded. Let’s see the following examples for better clarity :<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";"><br /></span></div>
<div class="MsoNormal">
<u><span style="font-family: "Verdana","sans-serif";"><b>ExampleMain.java</b><o:p></o:p></span></u></div>
<div class="MsoNormal">
<u><span style="font-family: "Verdana","sans-serif";"><br /></span></u></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">class
ExampleMain<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">public
static void main(String[] args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">System.out.println("Hiii");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">public
static void main(int x)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">System.out.println("Hello");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif";">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-family: "Verdana","sans-serif";">Output <o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-family: Verdana, sans-serif;">Hiii</span></div>
<br />
<div class="MsoNormal">
<br /></div>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-2662545541130216422018-01-02T02:12:00.000-08:002018-01-02T02:12:06.582-08:00JAVA 9 private method in interface<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;">Hii frnds, here we will know an exciting feature of
JAVA 9, that is definition of private method in interface. That means it is
possible that we can happily define a private method inside the interface.</span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><u><b><i>IntefaceExample.java</i></b></u></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;">interface Test</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;">{</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>void show();</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>default void print()</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>{</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>System.out.println("JAVA means SILAN TECHNOLOGY");</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>display();</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>}</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>private void display()</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>{</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>System.out.println("www.java8s.com");</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>}</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;">}</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;">class Demo implements Test</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;">{</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>public void show()</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>{</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>System.out.println("SILAN TECHNOLOGY");</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>}</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;">}</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;">class InterfaceExample</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;">{</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>public static void main(String[] args)</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>{</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>Demo obj=new Demo();</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>obj.show();</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>obj.print();</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-size: 13.3333px; white-space: pre;"><span style="font-family: Verdana, sans-serif;"> </span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><span style="white-space: pre;"> </span>}</span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 13.3333px;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-size: 13.3333px; line-height: 150%;"><span style="font-family: Verdana, sans-serif;">}</span></span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><br /></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"><b>Output</b></span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 150%;"> </span><span style="font-family: Verdana, sans-serif; font-size: 13.3333px;">SILAN TECHNOLOGY</span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif; font-size: 13.3333px;">JAVA means SILAN TECHNOLOGY</span></div>
<div class="MsoNormal" style="line-height: 150%; text-align: justify; text-justify: inter-ideograph;">
<span style="font-family: Verdana, sans-serif; font-size: 13.3333px;">www.java8s.com</span></div>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0tag:blogger.com,1999:blog-5021209514842285078.post-43017733677785835542017-12-18T08:13:00.002-08:002017-12-18T08:13:21.726-08:00Can we compile and execute a java program without a class??<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">Ans: Yes, we can compile and execute without a class.
Let’s see the following code:<o:p></o:p></span></div>
<div class="MsoNormal">
<u><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;"><br /></span></u></div>
<div class="MsoNormal">
<u><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">Test43.java<o:p></o:p></span></u></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">enum Test43{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">public static void main(String[] args)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">System.out.println("Silan Technology");<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;"><b><u>Output</u></b></span></div>
<div class="MsoNormal">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; line-height: 115%;">Silan Technology</span></div>
</div>
JavaByTrilochanhttp://www.blogger.com/profile/06225964990484529073noreply@blogger.com0