<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: arpitmandliya</title>
    <description>The latest articles on DEV Community by arpitmandliya (@arpitmandliya).</description>
    <link>https://dev.to/arpitmandliya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F143927%2Fd0bd05d3-5c50-4b0f-bbba-7f72673c9c3e.jpg</url>
      <title>DEV Community: arpitmandliya</title>
      <link>https://dev.to/arpitmandliya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arpitmandliya"/>
    <language>en</language>
    <item>
      <title>OpenCV Python tutorial</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Fri, 16 Oct 2020 06:48:14 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/opencv-python-tutorial-3dac</link>
      <guid>https://dev.to/arpitmandliya/opencv-python-tutorial-3dac</guid>
      <description>&lt;p&gt;OpenCV is a massive open source library for &lt;code&gt;computer vision, and picture processing&lt;/code&gt;. OpenCV supports a huge array of programming languages such as &lt;a href="https://www.code2master.com/python/python-tutorial-beginners/" rel="noopener noreferrer"&gt;Python&lt;/a&gt;, C++, Java, etc. It can process pictures and videos to identify items, faces and can be very useful in a lot of scenarios. &lt;br&gt;
For example: Auto tag feature used by facebook. When you upload a picture to &lt;code&gt;facebook&lt;/code&gt;, it automatically detects the person and suggests you tag the person.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OpenCV&lt;/code&gt; stands for open source computer vision library. It is widely used for image detection. It was first introduced by intel and was written in C/C++. It is generally used in Python for computer visions.&lt;/p&gt;
&lt;h2&gt;
  
  
  Install OpenCV on Windows and linux
&lt;/h2&gt;

&lt;p&gt;You need to install python first on your machine.&lt;br&gt;
You can check &lt;code&gt;python&lt;/code&gt; version using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Python&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use pip to install opencv. pip is standard package manager for Python and it will help you install packages not available in Python Standard library.&lt;br&gt;
To install OpenCV, just to command line and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;opencv&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="c1"&gt;#Python 2
&lt;/span&gt;&lt;span class="n"&gt;pip3&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;opencv&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="c1"&gt;#Python 3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to check if OpenCV is correctly installed, then you can use the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Python&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;cv2&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__version__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case you are using anaconda then you can use following command"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;conda&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="n"&gt;menpo&lt;/span&gt; &lt;span class="n"&gt;opencv3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case, you are getting modulenotfounderror, then you can use &lt;a href="https://java2blog.com/modulenotfounderror-no-module-named-cv2-python/" rel="noopener noreferrer"&gt;CV2 modulenotfounderror: no module named cv2&lt;/a&gt; to resolve the issue.&lt;/p&gt;

&lt;h2&gt;
  
  
  OpenCV Python tutorial
&lt;/h2&gt;

&lt;p&gt;This OpenCV tutorial will help you to understand the basic Image-processing with a lot of examples. &lt;/p&gt;

&lt;p&gt;It includes following tutorials:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://java2blog.com/python-introduction-installation-opencv/" rel="noopener noreferrer"&gt;OpenCV introduction&lt;/a&gt;: It provides quick introduction to openCV python library.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-imread-python/" rel="noopener noreferrer"&gt;CV2 imread&lt;/a&gt;: cv2 imread method is used to read image from path.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-imwrite-python/" rel="noopener noreferrer"&gt;CV2 imwrite&lt;/a&gt;: cv2 imwrite method is used to save image to the disk.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-imshow-python/" rel="noopener noreferrer"&gt;CV2 imshow&lt;/a&gt;: cv2 imshow is used to display image in the window.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-resize-python/" rel="noopener noreferrer"&gt;CV2 resize&lt;/a&gt;: cv2 resize is used to resize an image.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-videocapture-python/" rel="noopener noreferrer"&gt;CV2 videocapture&lt;/a&gt;: cv2 videocapature is used to read and start live streaming.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-threshold-python/" rel="noopener noreferrer"&gt;CV2 threshold&lt;/a&gt;: CV2 threshold is used to separate an object form the background in the image.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-canny-python/" rel="noopener noreferrer"&gt;CV2 canny&lt;/a&gt;: Cv2 canny method is used to detect edges in an image.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-findcontours-python/" rel="noopener noreferrer"&gt;CV2 findcontours&lt;/a&gt;: cv2 findcontours method is used find boundaries of an image.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-gaussianblur-python/" rel="noopener noreferrer"&gt;CV2 gaussianblur&lt;/a&gt;: CV2 gaussianblur is used to blur an image.&lt;br&gt;
&lt;a href="https://java2blog.com/cv2-cvtcolor-python/" rel="noopener noreferrer"&gt;CV2 cvtcolor&lt;/a&gt;: CV2 cvtcolor is used to convert color of an image from one color space to another.&lt;/p&gt;

</description>
      <category>python</category>
      <category>opencv</category>
    </item>
    <item>
      <title>Python tutorial for beginners</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Wed, 25 Sep 2019 17:32:00 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/python-tutorial-for-beginners-1lfo</link>
      <guid>https://dev.to/arpitmandliya/python-tutorial-for-beginners-1lfo</guid>
      <description>&lt;h2&gt;&lt;span&gt;What is Python?&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;Python is a popular programming language. It was created in 1991 by Guido van Rossum.It is one of the most easist programming language nowadays.&lt;br&gt;
Reason for Python popularity is due to the buzzwords - Big Data, Data mining, AI, IOT, Machine Learning etc.&lt;/p&gt;

&lt;p&gt;Now, these are the areas where it is easier to work with Python vis-a-vis Java. And these are the areas where Python is used more than Java . Python is being supported by large scientific community and academic institutions who have developed lots of library that makes easier to do jobs with Python.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.code2master.com/python/python-tutorial-beginners/"&gt;Python&lt;/a&gt; is a scripted language and is dynamically typed, so it’s usually easier to kick off a small project.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Features of Python are&lt;/span&gt;&lt;/h2&gt;

&lt;h3&gt;a. Easy&lt;/h3&gt;

&lt;p&gt;Python is very easy to learn and code.It is easier to get started with python due to its simplicity.&lt;/p&gt;

&lt;h3&gt;b. Interpreted&lt;/h3&gt;

&lt;p&gt;It is easy to test and debug as python is intrepreted language(line by line)&lt;/p&gt;

&lt;h3&gt;c. Portable&lt;/h3&gt;

&lt;p&gt;You can run Python on Windows, Mac, Linux or any other platform.&lt;/p&gt;

&lt;h3&gt;d. Object-Oriented&lt;/h3&gt;

&lt;p&gt;It supports classes and objects.&lt;/p&gt;

&lt;h3&gt;e. Free and Open Source&lt;/h3&gt;

&lt;p&gt;You don't need to buy costly licenses, it is free to use and supported by large number of python communities.&lt;/p&gt;

&lt;h3&gt;f. GUI Programming&lt;/h3&gt;

&lt;p&gt;You can use python to develop graphical user interface using dia&lt;/p&gt;

&lt;h3&gt;g. Large Library&lt;/h3&gt;

&lt;p&gt;Python provides you with a large standard library. Many academic institutions and scientific communities has developed large number of libraries which can use to apply for almost all the problems.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Frameworks available in Python&lt;/span&gt;&lt;/h2&gt;

&lt;h3&gt;a. Django&lt;/h3&gt;

&lt;p&gt;Django is a high-level open source Python Web framework. It takes care of much of the hassle of Web development, so you can focus on writing your app without using boiler plate code.&lt;/p&gt;

&lt;h3&gt;b. Tornado&lt;/h3&gt;

&lt;p&gt;Tornado is also open-source web framework, written in Python. It is known for its excellent performance and scalability.&lt;/p&gt;

&lt;h3&gt;c. Flask&lt;/h3&gt;

&lt;p&gt;Like Django, Flask is a web framework written in Python. It is a micro framework because it does not need certain libraries and tools. It also does not have form validation or a database abstraction layer. However, you can make use of extensions to add extra features. Pinterest and linkedin are some of biggest users of flask.&lt;/p&gt;

&lt;h3&gt;d. Pyramid&lt;/h3&gt;

&lt;p&gt;Pyramid is lightweight web framework. It is used to create web appication in easy way.&lt;/p&gt;

&lt;h3&gt;e. Bottle&lt;/h3&gt;

&lt;p&gt;Like Flask, it is a micro-framework for Python. It is used for web development. Bottle is known for its speed, simplicity, and light-weight. A single file can run both Python 2.5+ and 3.x&lt;/p&gt;

&lt;h3&gt;f. web2py&lt;/h3&gt;

&lt;p&gt;Written in Python, web2py is another open source web framework.It follows model view controller architecure(MVC) for web development.&lt;/p&gt;

&lt;h3&gt;g. NumPy&lt;/h3&gt;

&lt;p&gt;NumPy is an open-source framework for Python. It is used for scientific computing. It supports large multidimensional arrays and matrices, and functions to operate on them.&lt;/p&gt;

&lt;h3&gt;h. SciPy&lt;/h3&gt;

&lt;p&gt;SciPy is a Python library that you can use for scientific computing. It has modules for linear algebra, interpolation, fast Fourier transform, image processing, and many more. It uses a multidimensional array from the NumPy module.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's create some very simple program to add two numbers&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;
&lt;strong&gt;
a=10
b=20
print(a+b)&lt;/strong&gt;
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;30&lt;/p&gt;

&lt;p&gt;Here is python tutorial series.&lt;/p&gt;

&lt;h2 id="tutorial" class="autoscroll"&gt;Python tutorial&lt;/h2&gt;




&lt;h3&gt;&lt;span&gt;Python basics&lt;/span&gt;&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-hello-world/"&gt;Python hello world&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-keywords-identifiers-2/"&gt;Python keywords and identifiers&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-operators/"&gt;Python operators&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/if-else-statement-python/"&gt;Python If else statment&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-for-loop/"&gt;Python for loop&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-while-loop/"&gt;Python while loop&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-function/"&gt;Python function example&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-print-format/"&gt;Python print format&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





&lt;h3&gt;&lt;span&gt;Python data structures&lt;/span&gt;&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-string/"&gt;Python String&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list/"&gt;Python list&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-dictionary/"&gt;Python Dictionary&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-tuple/"&gt;Python tuple&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-set/"&gt;Python set&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





&lt;h3&gt;&lt;span&gt;Python List operations&lt;/span&gt;&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-append/"&gt;Python list append&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-extend/"&gt;Python list extend&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-clear/"&gt;Python list clear&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-sort/"&gt;Python list sort&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-reverse/"&gt;Python list reverse&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-insert/"&gt;Python list insert&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-copy/"&gt;Python list copy&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-pop/"&gt;Python list pop&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-index/"&gt;Python list index&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-remove/"&gt;Python list remove&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





&lt;h3&gt;&lt;span&gt;Python programs&lt;/span&gt;&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-program-check-number-positive-negative-zero/"&gt;Python program to check number is positive or negative&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-gcd-function/"&gt;Python gcd function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-program-check-prime-number/"&gt;Python program to check prime number&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-sort/"&gt;Python program to check prime number in intervals&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-program-check-armstrong-number/"&gt;Python program to check armstrong number&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-program-check-number-even-odd/"&gt;Python program to check if number is even or odd&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/find-square-root-number-python/"&gt;Python program to find square root of number&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/reverse-number-python/"&gt;Python program to reverse number&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-program-find-factors-number/"&gt;Python Program to Find Factors of Number&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-program-check-palindrome-string/&amp;gt;Python%20program%20to%20check%20palindrome%20String&amp;lt;/a&amp;gt;&amp;lt;br%20/&amp;gt;%20&amp;lt;a%20href="&gt;factorial program in python&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="%20https://www.code2master.com/python/python-program-find-largest-among-three-numbers/&amp;gt;Python%20Program%20to%20Find%20the%20Largest%20Among%20Three%20Numbers&amp;lt;/a&amp;gt;&amp;lt;br%20/&amp;gt;%20&amp;lt;a%20href="&gt;Python Program to check leap year&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="%20https://www.code2master.com/python/convert-decimal-to-binary-octal-and-hexadecimal-python/&amp;gt;Python%20Program%20to%20Convert%20Decimal%20to%20Binary,%20Octal%20and%20Hexadecimal&amp;lt;/a&amp;gt;&amp;lt;br%20/&amp;gt;%20&amp;lt;a%20href="&gt;Python Program to Find the Sum of Natural Numbers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





&lt;h3&gt;&lt;span&gt;Python functions&lt;/span&gt;&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-range-function/"&gt;Python range function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-abs/"&gt;Python abs function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-dir/"&gt;Python dir function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-repr/"&gt;Python repr function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-chr/"&gt;Python chr function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-dict-function/"&gt;Python dict function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-getattr/"&gt;Python getattr function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-hasattr/"&gt;Python hasattr function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-delattr/"&gt;Python delattr function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-bool/"&gt;Python bool function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-setattr/"&gt;Python setattr function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-bin/"&gt;Python bin function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-vars/"&gt;Python vars function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-enumerate/"&gt;Python enumerate function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-divmod/"&gt;Python divmod function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-isinstance/"&gt;Python isinstance function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-sorted-function/"&gt;Python sorted function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-function/"&gt;Python list function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-tuple-function/"&gt;Python tuple function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-set-function/"&gt;Python set function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-map-function/"&gt;Python map function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-oct/"&gt;Python ocr function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-hex/"&gt;Python hex function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-ord/"&gt;Python ord function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-pow/"&gt;Python pow function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-next/"&gt;Python next function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-sum-function/"&gt;Python sum function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-zip-function/"&gt;Python zip function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-frozenset/"&gt;Python frozenset function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-round-function/"&gt;Python rouns function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-max-function/"&gt;Python max function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-min-function/"&gt;Python min function&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-filter-example/"&gt;Python filter function&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





&lt;h3&gt;&lt;span&gt;Python datetime&lt;/span&gt;&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-datetime/"&gt;Python datetime&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/get-current-date-and-time-python/"&gt;Python get current date and time&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-timeit/"&gt;Python timeit&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-convert-string-to-datetime/"&gt;How to convert String to datetime in python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





&lt;h3&gt;&lt;span&gt;Python utility programs&lt;/span&gt;&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-split-string-into-list/"&gt;How to split string into list in Python&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-check-list-empty/"&gt;python - check if list is empty&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-set-to-list/"&gt;How to convert set to list in Python&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-list-to-set/"&gt;How to convert list to set in Python&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://www.code2master.com/python/python-compare-strings/"&gt;How to compare Strings in Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's all about Python tutorial for beginners.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understand Garbage Collection in java</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Tue, 16 Jul 2019 16:47:40 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/understand-garbage-collection-in-java-54bh</link>
      <guid>https://dev.to/arpitmandliya/understand-garbage-collection-in-java-54bh</guid>
      <description>&lt;p&gt;In this post, we will see about Garbage Collection in &lt;a href="https://java2blog.com/core-java-tutorial-for-beginners-experienced/" rel="noopener noreferrer"&gt;java&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I will try to explain with the help of diagrams and examples rather than theory.&lt;/p&gt;

&lt;p&gt;JVM Memory is divided into three parts&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Young generation&lt;/li&gt;
    &lt;li&gt;Old generation&lt;/li&gt;
    &lt;li&gt;Metaspace (Perm Gen)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;&lt;span&gt;Young Generation&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;As the name suggests, young generation is the area where newly created &lt;a href="https://java2blog.com/object-class-java/" rel="noopener noreferrer"&gt;objects&lt;/a&gt; are allocated.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;When young generation fills up, it cause minor garbage collection aka Minor GC.&lt;/li&gt;
    &lt;li&gt;When minor Gcs occurs, dead objects will be removed from young generation.&lt;/li&gt;
    &lt;li&gt;If you have lot of dead objects in young generation, Minor GC will be perfomed faster.&lt;/li&gt;
    &lt;li&gt;All minor GCs are "stop the world" events, so when minor GCs occurs, application threads will also stop.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's understand more about how objects are allocated in Young generation.&lt;/p&gt;

&lt;p&gt;Young generation is divided into 3 parts.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Eden space&lt;/li&gt;
    &lt;li&gt;Survivor space S0&lt;/li&gt;
    &lt;li&gt;Survivor space S1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is illustration of the young and old generation.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F05%2FYoungOldGeneration-1024x733.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F05%2FYoungOldGeneration-1024x733.png" alt="YoungOldGeneration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;
&lt;ul&gt;
    &lt;li&gt;All newly created objects are allocated in eden space.&lt;/li&gt;
    &lt;li&gt;When Eden space is completely filled with objects then minor GC will occur. All the objects which are not dead or unreferenced will be moved to one of the survivors spaces. In our case, let's say all the objects are moved to S0.&lt;/li&gt;
&lt;/ul&gt;




&lt;/li&gt;


&lt;/ul&gt;
&lt;br&gt;&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FEdenToS0ObjectsAllocation.jpg" alt=""&gt;&lt;br&gt;&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FS0AllocatedObjects.jpg" alt="S0AllocatedObjects"&gt;

&lt;ul&gt;
    &lt;li&gt;
&lt;ul&gt;
    &lt;li&gt;When Eden space is filled again, then all the live objects in Eden space andSurvivor space S0 will be moved to Survivor space S1.&lt;/li&gt;
&lt;/ul&gt;




&lt;/li&gt;


&lt;/ul&gt;
&lt;br&gt;&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FS0T0S1AlloactedObjects.jpg" alt="S0T0S1AlloactedObjects"&gt;&lt;br&gt;&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FS1AllocatedObjects.jpg" alt="S1AllocatedObjects"&gt;

&lt;ul&gt;
    &lt;li&gt;Once objects are survived multiple cycles of minor GC, they will be moved to old generation. You can control this threshold by MaxTenuringThreshold. The actual tenuring threshold is dynamically adjusted by JVM.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's try to demonstrate this behavior with the help of example:&lt;br&gt;
You have below class in which I am creating short-lived objects for demonstration.&lt;/p&gt;

&lt;pre&gt;package org.arpit.java2blog;

import java.math.BigDecimal;

public class GCCollectorExample {
    public static void main(String args[])
    {
        createObjects();
    }
    private static void createObjects() {

        long count = 0;
        
        while(true) { 
            // Creating short-lived objects just for illustration
            BigDecimal shortLivedBigDecimal1 = new BigDecimal(count++);
        }
    }
}
&lt;/pre&gt;

&lt;p&gt;When you run the program. Let's check memory allocation in Visual GC (A visualVM plugin)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FS0AndEdenDemonstation-1024x422.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FS0AndEdenDemonstation-1024x422.png" alt="S0AndEdenDemonstation-1024x422"&gt;&lt;/a&gt;&lt;br&gt;
As you can see, we have few objects in S0 and once eden space is completely filled, all referenced objects will be moved to S1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FS1FilledAndEdenDemonstration-1024x424.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FS1FilledAndEdenDemonstration-1024x424.png" alt="S1FilledAndEdenDemonstration"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Old generation&lt;/span&gt;&lt;/h2&gt;

&lt;ul&gt;
    &lt;li&gt;It is used to hold old long surviving objects&lt;/li&gt;
    &lt;li&gt;It is generally larger than the young generation.&lt;/li&gt;
    &lt;li&gt;When tenured space is completely filled(or predefined threshold) with objects then Major GC will occur. It will reclaim the memory and free up space.&lt;/li&gt;
    &lt;li&gt;Often, Major GCs are slower and less frequent than minor GC.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How can you use this information to optimize memory?&lt;/strong&gt;&lt;br&gt;
It depends on nature of application.&lt;br&gt;
If you have lots of temporary objects then there will be lot of minor gc. You can provide arguments XX:NewRatio=1 to distribute 50% to young generation and 50% to old.&lt;br&gt;
By default, NewRatio=2 hence young Generation is 1/3 of total heap.&lt;br&gt;
Similarly, If you have too many long-lived objects, then you might need to increase size of tenure space by putting high value of NewRatio.&lt;/p&gt;

&lt;h3&gt;Why two survivor spaces?&lt;/h3&gt;

&lt;p&gt;You must be wondering why do we have 2 survivor space. We have 2 survivor spaces to avoid memory fragmentation. Each time you copy objects from eden to survivor and you get empty eden space and 1 empty survivor space.&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Garbage Collection Algorithms&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;JVM comes with several algorithms for young and old generation. There are 3 types of algorithms&lt;/p&gt;

&lt;h3&gt;serial collector&lt;/h3&gt;

&lt;p&gt;It uses single thread to perform all the garbage collection and is suitable for basic application with single processor machines.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FSerialGC.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FSerialGC.jpg" alt="SerialGC"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Parallel collector&lt;/h3&gt;

&lt;p&gt;It uses multiple CPUs to perform garbage collector. While serial collector uses 1 thread to perform GC, parallel GC uses several threads to perform GC and it is useful when there is enough memory and good number of cores.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FparallelGC.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FparallelGC.jpg" alt="ParallelGC"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Concurrent collector&lt;/h3&gt;

&lt;p&gt;Concurrent collector performs garbage collection with application threads. It is useful for applications which have medium to large datasets and require quick response time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FconcurrentGC.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2019%2F07%2FconcurrentGC.jpg" alt="concurrentGC"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use different GC algorithms for young and old generations but you can pair only compatible algorithms.&lt;/p&gt;

&lt;p&gt;For example: You can not pair Parallel Scavenge for young generation to Concurrent mark sweep for old as parallel scavenge does not provide synchronization which is required in CMS.&lt;/p&gt;

&lt;p&gt;Here are garbage collectors which you can use for young and old generation.&lt;br&gt;
[table id=17 /]&lt;/p&gt;

&lt;p&gt;There are a lot of changes in garbage collectors after&lt;a href="https://java2blog.com/java-8-tutorial/" rel="noopener noreferrer"&gt; Java 8&lt;/a&gt;, I will try to cover them in my next articles.&lt;/p&gt;

&lt;p&gt;If you have any suggestions on this article, please comment.&lt;br&gt;
&lt;strong&gt;Original post:&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://java2blog.com/garbage-collection-java/" rel="noopener noreferrer"&gt;Garbage Collection in java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may also like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://java2blog.com/core-java-tutorial-for-beginners-experienced/" rel="noopener noreferrer"&gt;Core java tutorial&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://java2blog.com/introduction-to-spring-framework/" rel="noopener noreferrer"&gt;Spring tutorial&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://java2blog.com/spring-mvc-tutorial/" rel="noopener noreferrer"&gt;Spring MVC tutorial&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://java2blog.com/spring-boot-web-application-example/" rel="noopener noreferrer"&gt;Spring boot web application example&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://java2blog.com/spring-boot-hibernate-example/" rel="noopener noreferrer"&gt;Spring boot hibernate example&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://java2blog.com/spring-boot-interview-questions/" rel="noopener noreferrer"&gt;Spring boot interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="https://java2blog.com/spring-interview-questions-and-answers/" rel="noopener noreferrer"&gt;Spring interview questions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>java</category>
      <category>memorymanagement</category>
      <category>programming</category>
      <category>coding</category>
    </item>
    <item>
      <title>How HashMap works internally in java : A debug approach</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Fri, 03 May 2019 18:26:27 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/how-hashmap-works-internally-in-java-a-debug-approach-58fn</link>
      <guid>https://dev.to/arpitmandliya/how-hashmap-works-internally-in-java-a-debug-approach-58fn</guid>
      <description>&lt;p&gt;Most common interview questions are "How HashMap works in &lt;a href="https://java2blog.com/core-java-tutorial-for-beginners-experienced/" rel="noopener noreferrer"&gt;java&lt;/a&gt;", "How get and put method of &lt;a href="https://java2blog.com/hashmap-in-java-with-examples/" rel="noopener noreferrer"&gt;HashMap&lt;/a&gt; work internally". Here I am trying to explain internal functionality with an easy example. HashMap is one of the most used &lt;a href="https://java2blog.com/collections-java/" rel="noopener noreferrer"&gt;Collections in java&lt;/a&gt;.Rather than going through theory, we will start with example first, so that you will get better understanding and then we will see how get and put function work in java.&lt;/p&gt;



&lt;p&gt;Let's take a very simple example. I have a Country class, we are going to use Country class object as key and its capital name(string) as value. Below example will help you to understand, how these key value pair will be stored in hashmap.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;1. Country.java &lt;/b&gt;&lt;/p&gt;

&lt;pre&gt;package org.arpit.java2blog;
public class Country {

    String name;
    long population;

    public Country(String name, long population) {
        super();
        this.name = name;
        this.population = population;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public long getPopulation() {
        return population;
    }
    public void setPopulation(long population) {
        this.population = population;
    }

    // If length of name in country object is even then return 31(any random number) and if odd then return 95(any random number).
    // This is not a good practice to generate hashcode as below method but I am doing so to give better and easy understanding of hashmap.
    &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;
    public int hashCode() {
        if(this.name.length()%2==0)
            return 31;
        else 
            return 95;
    }
    &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;
    public boolean equals(Object obj) {

        Country other = (Country) obj;
        if (name.equalsIgnoreCase((other.name)))
            return true;
        return false;
    }

}&lt;/pre&gt;
If you want to understand more about hashcode and equals method of object, you may refer&lt;b&gt; &lt;a href="http://www.java2blog.com/2014/02/hashcode-and-equals-method-in-java.html" rel="noopener noreferrer"&gt;hashcode() and equals() method in java&lt;/a&gt;&lt;/b&gt;

&lt;b&gt;2. HashMapStructure.java&lt;/b&gt;(main class)
&lt;pre&gt;import java.util.HashMap;
import java.util.Iterator;

public class HashMapStructure {

    /**
     * @author Arpit Mandliya
     */
    public static void main(String[] args) {

        Country india=new Country("India",1000);
        Country japan=new Country("Japan",10000);

        Country france=new Country("France",2000);
        Country russia=new Country("Russia",20000);

        HashMap&amp;lt;Country, String&amp;gt; countryCapitalMap=new HashMap&amp;lt;Country,String&amp;gt;();  
        countryCapitalMap.put(india,"Delhi");  
        countryCapitalMap.put(japan,"Tokyo");  
        countryCapitalMap.put(france,"Paris");  
        countryCapitalMap.put(russia,"Moscow");  

        Iterator countryCapitalIter=countryCapitalMap.keySet().iterator();//put debug point at this line  
        while(countryCapitalIter.hasNext())  
        {  
            Country countryObj=countryCapitalIter.next();  
            String capital=countryCapitalMap.get(countryObj);  
            System.out.println(countryObj.getName()+"----"+capital);  
        }  
    }  


}&lt;/pre&gt;
Now put debug point at line 24 and right click on project-&amp;gt;debug as-&amp;gt; java application. Program will stop execution at line 24 then right click on countryCapitalMap then select watch.You will be able to see structure as below.
&lt;a href="http://3.bp.blogspot.com/-T4TsTlhwaXU/Uwjj9ypm69I/AAAAAAAACsY/J4-a6rxZLLE/s1600/HashMapStructure1.bmp" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D6eNxngU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://3.bp.blogspot.com/-T4TsTlhwaXU/Uwjj9ypm69I/AAAAAAAACsY/J4-a6rxZLLE/s1600/HashMapStructure1.bmp" width="800" height="454"&gt;&lt;/a&gt;
Now From above diagram, you can observe the following points
&lt;ol&gt;
    &lt;li&gt;
&lt;ol&gt;
    &lt;li&gt;There is an Entry[] array called table which has size 16.&lt;/li&gt;
    &lt;li&gt;This table stores Entry class's object. HashMap class has an inner class called Entry. This Entry have key value as an instance variable. Let's see structure of entry class Entry Structure.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;static class Entry implements Map.Entry
{
        final K key;
        V value;
        Entry next;
        final int hash;
        ...//More code goes here
}&lt;/pre&gt;
&lt;ol&gt;
    &lt;li&gt;Whenever we try to put any key value pair in hashmap, Entry class object is instantiated for key value and that object will be stored in above mentioned Entry[](table). Now you must be wondering, where will above created Enrty object get stored(exact position in table). The answer  is, hash code is calculated for a key by calling Hascode() method. This hashcode is used to calculate index for above Entry[] table.&lt;/li&gt;
    &lt;li&gt;Now, If you see at array index 10 in above diagram, It has an Entry object named HashMap$Entry.&lt;/li&gt;
    &lt;li&gt;We have put 4 key-values in hashmap but it seems to have only 2!!!! This is because if two objects have same hashcode, they will be stored at same index. Now the question arises how? It stores objects in the form of LinkedList(logically).&lt;/li&gt;
&lt;/ol&gt;
So how hashcode of above country key-value pairs are calculated.
&lt;pre&gt;Hashcode for Japan = 95 as its length is odd.
Hashcode for India =95 as its length is odd
HashCode for Russia=31 as its length is even.
HashCode for France=31 as its length is even.

&lt;/pre&gt;

&lt;p&gt;Below diagram will explain LinkedList concept clearly.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://1.bp.blogspot.com/-uBsIhju_rS0/Uwjnm9ngraI/AAAAAAAACsk/0NoA3f6iHqI/s1600/HashMapStructure2.bmp" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KrFaFK_X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://1.bp.blogspot.com/-uBsIhju_rS0/Uwjnm9ngraI/AAAAAAAACsk/0NoA3f6iHqI/s1600/HashMapStructure2.bmp" width="797" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now if you have good understanding of hashmap structure,Lets go through put and get method.&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Put&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;Let's see the implementation of put method:&lt;/p&gt;



&lt;pre&gt;       /**
         * Associates the specified value with the specified key in this map. If the
         * map previously contained a mapping for the key, the old value is
         * replaced.
         *
         * &lt;a class="mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt; key
         *            key with which the specified value is to be associated
         * &lt;a class="mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt; value
         *            value to be associated with the specified key
         * @return the previous value associated with key, or null
         *         if there was no mapping for key. (A null return
         *         can also indicate that the map previously associated
         *         null with key.)
         */
        public V put(K key, V value) {
            if (key == null)
                return putForNullKey(value);
            int hash = hash(key.hashCode());
            int i = indexFor(hash, table.length);
            for (Entry e = table[i]; e != null; e = e.next) {
                Object k;
                if (e.hash == hash &amp;amp;&amp;amp; ((k = e.key) == key || key.equals(k))) {
                    V oldValue = e.value;
                    e.value = value;
                    e.recordAccess(this);
                    return oldValue;
                }
            }

            modCount++;
            addEntry(hash, key, value, i);
            return null;
        }&lt;/pre&gt;
now lets understand above code step by step
&lt;ol&gt;
    &lt;li&gt;Key object is checked for null. If key is null then it will be stored at table[0] because hashcode for null is always 0.&lt;/li&gt;
    &lt;li&gt;Key object's hashcode() method is called and hash code is calculated. This hashcode is used to find index of array for storing Entry object. It may happen sometimes that, this hashcode function is poorly written so JDK designer has put another function called hash() which takes above-calculated hash value as argument. If you want to learn more about hash() function, you can refer &lt;a href="http://www.java2blog.com/2014/02/hash-and-indexfor-method-in-hashmap.html" rel="noopener noreferrer"&gt;hash and indexFor method in hashmap&lt;/a&gt;.&lt;/li&gt;
    &lt;li&gt;indexFor(hash,table.length)  is used to calculate exact index in table array for storing the Entry object.&lt;/li&gt;
    &lt;li&gt;As we have seen in our example, if two key objects have same hashcode(which is known as &lt;b&gt;collision&lt;/b&gt;) then it will be stored in form of linkedlist.So here, we will iterate through our linkedlist.
&lt;ul&gt;
    &lt;li&gt;If there is no element present at that index which we have just calculated then it will directly put our Entry object at that index.&lt;/li&gt;
    &lt;li&gt;If There is element present at that index then it will iterate until it gets Entry-&amp;gt;next as null.&lt;/li&gt;
    &lt;li&gt;What if we are putting same key again, logically it should replace old value. Yes, it will do that. While iterating it will check key equality by calling equals() method(&lt;b&gt;key.equals(k)&lt;/b&gt;), if this method returns true then it replaces value object with current Entry's value object.&lt;/li&gt;
    &lt;li&gt;If it did not find the duplicate key, then current Entry object will become first node in linkedlist and current Entry -&amp;gt; next will become an existing first node on that index.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;&lt;span&gt;Get&lt;/span&gt;&lt;/h2&gt;
&lt;b&gt; &lt;/b&gt;Lets see implementation of get now:
&lt;pre&gt;/**
     * Returns the value to which the specified key is mapped, or {@code null}
     * if this map contains no mapping for the key.
     *
     *
     * More formally, if this map contains a mapping from a key {@code k} to a
     * value {@code v} such that {@code (key==null ? k==null :
     * key.equals(k))}, then this method returns {@code v}; otherwise it returns
     * {@code null}. (There can be at most one such mapping.)
     *
     *
     * A return value of {@code null} does not necessarily indicate that
     * the map contains no mapping for the key; it's also possible that the map
     * explicitly maps the key to {@code null}. The {&lt;a class="mentioned-user" href="https://dev.to/link"&gt;@link&lt;/a&gt; #containsKey
     * containsKey} operation may be used to distinguish these two cases.
     *
     * &lt;a class="mentioned-user" href="https://dev.to/see"&gt;@see&lt;/a&gt; #put(Object, Object)
     */
    public V get(Object key) {
        if (key == null)
            return getForNullKey();
        int hash = hash(key.hashCode());
        for (Entry e = table[indexFor(hash, table.length)]; e != null; e = e.next) {
            Object k;
            if (e.hash == hash &amp;amp;&amp;amp; ((k = e.key) == key || key.equals(k)))
                return e.value;
        }
        return null;
    }
&lt;/pre&gt;

&lt;p&gt;As you got the understanding on put functionality of hashmap. So to understand get functionality is quite simple. If you pass any key to get value object from hashmap.&lt;/p&gt;

&lt;ol&gt;
    &lt;li&gt;Key object is checked for null. If key is null then value of Object resides at table[0] will be returned.&lt;/li&gt;
    &lt;li&gt;Key object's hashcode() method is called and hash code is calculated.&lt;/li&gt;
    &lt;li&gt;indexFor(hash,table.length)  is used to calculate exact index in table array using generated hashcode for getting the Entry object.&lt;/li&gt;
    &lt;li&gt;After getting index in table array, it will iterate through linkedlist and check for key equality by calling equals() method and if it returns true then it returns the value of Entry object else returns null.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Key points to Remeber:&lt;/h3&gt;

&lt;ul&gt;
    &lt;li&gt;HashMap has a inner class called Entry which stores key-value pairs.&lt;/li&gt;
    &lt;li&gt;Above Entry object is stored in Entry[ ](Array) called table&lt;/li&gt;
    &lt;li&gt;An index of table is logically known as bucket and it stores first element of linkedlist&lt;/li&gt;
    &lt;li&gt;Key object's &lt;a href="https://java2blog.com/hashcode-and-equals-method-in-java/" rel="noopener noreferrer"&gt;hashcode&lt;/a&gt;() is used to find bucket of that Entry object.&lt;/li&gt;
    &lt;li&gt;If two key object 's have same hashcode , they will go in same bucket of table array.&lt;/li&gt;
    &lt;li&gt;Key object 's equals() method is used to ensure uniqueness of key object.&lt;/li&gt;
    &lt;li&gt;Value object  's equals() and hashcode() method is not used at all&lt;/li&gt;
&lt;/ul&gt;


&lt;span&gt;Please go through &lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;a href="http://www.java2blog.com/2016/07/core-java-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;core java interview questions&lt;/a&gt;&lt;span&gt; and &lt;a href="https://java2blog.com/java-interview-questions/" rel="noopener noreferrer"&gt;java interview questions&lt;/a&gt; for more interview questions.

&lt;p&gt;Originally posted on Java2blog with title &lt;a href="https://java2blog.com/how-hashmap-works-in-java/" rel="noopener noreferrer"&gt;How HashMap works in java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may also like&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/04/hashmap-in-java-with-examples.html" rel="noopener noreferrer"&gt;HashMap in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2014/02/how-hashmap-works-in-java.html" rel="noopener noreferrer"&gt;How HashMap works in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2014/02/hash-and-indexfor-method-in-hashmap.html" rel="noopener noreferrer"&gt;hash and indexfor method in HashMap&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2014/02/hashcode-and-equals-method-in-java.html" rel="noopener noreferrer"&gt;hashcode and equals method in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/05/how-to-sort-hashmap-in-java-by-keys-and.html" rel="noopener noreferrer"&gt;How to sort HashMap by keys and values&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;
&lt;a href="http://www.java2blog.com/2013/02/difference-between-hashmap-and-hashset.html" rel="noopener noreferrer"&gt;Difference between HashMap and Hash&lt;/a&gt;&lt;a href="http://www.java2blog.com/2013/02/difference-between-hashmap-and-hashset.html" rel="noopener noreferrer"&gt;Set&lt;/a&gt;
&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2013/02/difference-between-hashtable-and-hashmap.html" rel="noopener noreferrer"&gt;Difference between HashMap and Hashtable&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2015/06/how-to-iterate-over-map-or-hashmap-in.html" rel="noopener noreferrer"&gt;How to iterate over HashMap&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;/span&gt;

</description>
      <category>java</category>
      <category>collections</category>
      <category>hashmap</category>
      <category>interview</category>
    </item>
    <item>
      <title>Introduction to Restful web services</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Sat, 27 Apr 2019 05:53:47 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/introduction-to-restful-web-services-22ga</link>
      <guid>https://dev.to/arpitmandliya/introduction-to-restful-web-services-22ga</guid>
      <description>&lt;p&gt;In this post, we will see RESTful web service introduction.&lt;/p&gt;

&lt;p&gt;REST is an architectural style which was brought in by Roy Fielding in 2000 in his doctoral thesis. In the web services terms, REpresentational State Transfer (REST) is a stateless client-server architecture in which the web services are viewed as resources and can be identified by their URIs. Web service clients that want to use these resources access via globally defined set of remote methods that describe the action to be performed on the resource.&lt;/p&gt;

&lt;p&gt;It consists of two components REST server which provides access to the resources and a REST client which accesses and modify the REST resources.&lt;/p&gt;

&lt;p&gt;In the REST architecture style, clients and servers exchange representations of resources by using a standardized interface and protocol.REST isn't protocol specific, but when people talk about REST they usually mean REST over HTTP.&lt;br&gt;
The response from server is considered as the representation of the resources. This representation can be generated from one resource or more number of resources.&lt;br&gt;
&lt;a href="http://www.java2blog.com/wp-content/uploads/2013/04/RestfuArchitecture.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F4.bp.blogspot.com%2F-AG9PUSpz2Ss%2FUV1o7jnPRlI%2FAAAAAAAAA90%2F1qI9M2lZqnE%2Fs1600%2FRestfuArchitecture.jpg"&gt;&lt;/a&gt;&lt;br&gt;
REST allows that resources have different representations, e.g.xml, json etc. The rest client can ask for specific representation via the HTTP protocol.&lt;/p&gt;

&lt;h3&gt;HTTP methods :&lt;/h3&gt;

&lt;p&gt;RESTful web services use HTTP protocol methods for the operations they perform.Methods are:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;
&lt;b&gt;GET&lt;/b&gt;:It defines a reading access of the resource without side-effects.This operation is idempotent i.e.they can be applied multiple times without changing the result&lt;/li&gt;
    &lt;li&gt;
&lt;b&gt;PUT&lt;/b&gt; :  It is generally used for updating resouce.It must also be idempotent.&lt;/li&gt;
    &lt;li&gt;
&lt;b&gt;DELETE &lt;/b&gt;: It removes the resources. The operations are idempotent i.e. they can get repeated without leading to different results.&lt;/li&gt;
    &lt;li&gt;
&lt;b&gt;POST&lt;/b&gt; :It is used for creating a new resource. It is not idempotent.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Idempotent&lt;/b&gt; means result of multiple successful request will not change state of resource after initial application&lt;br&gt;
For example :&lt;br&gt;
Delete is idempotent method because when you first time use delete, it will delete the resource (initial application) but after that, all other request will have no result because resource is already deleted.&lt;/p&gt;

&lt;p&gt;Post is not idempotent method because when you use post to create resource , it will keep creating resource for each new request, so result of multiple successful request will not be same.&lt;/p&gt;

&lt;h2&gt;Features of RESTful web services:&lt;/h2&gt;

&lt;p&gt;&lt;b&gt;Resource identification through URI&lt;/b&gt;:Resources are identified by their URIs (typically links on internet). So, a client can directly access a RESTful Web Services using the URIs of the resources (same as you put a website address in the browser’s address bar and get some representation as response).&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Uniform interface&lt;/b&gt;: Resources are manipulated using a fixed set of four create, read, update, delete operations: PUT, GET, POST, and DELETE.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Client-Server&lt;/b&gt;: A clear separation concerns is the reason behind this constraint. Separating concerns between the Client and Server helps improve portability in the Client and Scalability of the server components.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Stateless&lt;/b&gt;: each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored context on the server.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Cache&lt;/b&gt;: to improve network efficiency responses must be capable of being labeled as cacheable or non-cacheable.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Named resources&lt;/b&gt; - the system is comprised of resources which are named using a URL.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Interconnected resource representations&lt;/b&gt; - the representations of the resources are interconnected using URLs, thereby enabling a client to progress from one state to another.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Layered components&lt;/b&gt; - intermediaries, such as proxy servers, cache servers, gateways, etc, can be inserted between clients and resources to support performance, security, etc.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Self-descriptive messages&lt;/b&gt;: Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML, XML, plain text, PDF, JPEG, JSON, and others.&lt;/p&gt;

&lt;p&gt;You can also check &lt;a href="http://www.java2blog.com/2016/06/restful-web-services-interview-questions.html" rel="noopener noreferrer"&gt;Restful interview questions with answers for beginners and experienced&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Web service Tutorial Content:&lt;/h2&gt;



&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://java2blog.com/2013/03/web-service-tutorial.html" rel="noopener noreferrer"&gt;Web services in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/06/web-services-interview-questions.html" rel="noopener noreferrer"&gt;Web services interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://java2blog.com/2013/03/soap-web-service-tutorial.html" rel="noopener noreferrer"&gt;SOAP web service introduction&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://java2blog.com/2013/04/restful-web-service-tutorial.html" rel="noopener noreferrer"&gt;RESTful web service introduction&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/06/difference-between-soap-and-rest-web-services.html" rel="noopener noreferrer"&gt;Difference between SOAP and REST web services&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://java2blog.com/2013/03/soap-web-service-example-in-java-using.html" rel="noopener noreferrer"&gt;SOAP web service example in java using eclipse&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://java2blog.com/2013/03/jaxws-web-service-eclipse-tutorial.html" rel="noopener noreferrer"&gt;JAX-WS web service eclipse tutorial&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://java2blog.com/2013/03/jaxws-webservice-deployement-on-tomcat.html" rel="noopener noreferrer"&gt;JAX-WS web service deployment on tomcat&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://java2blog.com/2013/04/create-restful-web-servicesjax-rs-using.html" rel="noopener noreferrer"&gt;Create RESTful web service in java(JAX-RS) using jersey&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2015/10/restful-web-services-jaxrs-json-example.html" rel="noopener noreferrer"&gt;RESTful web service &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2015/10/restful-web-services-jaxrs-json-example.html" rel="noopener noreferrer"&gt;JAJSONexample using jersey&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/03/restful-web-services-jaxrs-crud-example.html" rel="noopener noreferrer"&gt;RESTful web service &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/03/restful-web-services-jaxrs-crud-example.html" rel="noopener noreferrer"&gt;JAXRS CRUD example using jersey&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/03/angularjs-restful-web-service-example.html" rel="noopener noreferrer"&gt;AngularJS RESTful web service &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/03/angularjs-restful-web-service-example.html" rel="noopener noreferrer"&gt;JAXRS CRUD example using $http&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2015/10/restful-web-services-jax-rs-queryparam.html" rel="noopener noreferrer"&gt;RESTful Web Services (JAX-RS) @QueryParam Example&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2015/09/spring-restful-web-services-example.html" rel="noopener noreferrer"&gt;Spring Rest simple example&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2015/09/spring-restful-web-services-json-example.html" rel="noopener noreferrer"&gt;Spring Rest json example&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/08/spring-restful-web-services-xml-example.html" rel="noopener noreferrer"&gt;Spring Rest xml example&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/2016/04/spring-restful-web-services-crud-example.html" rel="noopener noreferrer"&gt;Spring Rest CRUD example&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;



</description>
      <category>java</category>
      <category>webservices</category>
      <category>rest</category>
      <category>restful</category>
    </item>
    <item>
      <title>Java interview questions for 4 to 7 years experience</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Mon, 22 Apr 2019 17:03:47 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/java-interview-questions-for-4-to-7-years-experience-17k9</link>
      <guid>https://dev.to/arpitmandliya/java-interview-questions-for-4-to-7-years-experience-17k9</guid>
      <description>&lt;p&gt;In this post, we will see &lt;a href="https://java2blog.com/java-interview-questions/" rel="noopener noreferrer"&gt;Java interview questions&lt;/a&gt; for 5 to 6 years experience.&lt;br&gt;
When you have 5 years of experience as &lt;a href="https://java2blog.com/core-java-tutorial-for-beginners-experienced/" rel="noopener noreferrer"&gt;java&lt;/a&gt; developer, you need to have good understanding of &lt;a href="https://www.java2blog.com/java-collections-interview-questions/" rel="noopener noreferrer"&gt;collections&lt;/a&gt;, &lt;a href="https://www.java2blog.com/java-multithreading-interview-questions-and-answers/" rel="noopener noreferrer"&gt;multithreading&lt;/a&gt; concepts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WE-JJFcg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/6cbw1ztv8nunbra4v1ek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WE-JJFcg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/6cbw1ztv8nunbra4v1ek.png" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are looking for below queries then this post will help you as well.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Java interview questions for 4 years experience&lt;/li&gt;
    &lt;li&gt;Java interview questions for 6 years experience&lt;/li&gt;
    &lt;li&gt;Java interview questions for 7 years experience&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some questions which are most asked for 5 years experience java programmers. You might find some of the questions very easy but believe me most developers failed to answer these questions.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;1. Guess the output of below program.&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;package org.arpit.java2blog;
class A
{
    void m1()
    {
        System.out.println("In m1 A");
    }
}
class B extends A
{
    void m1()
    {
        System.out.println("In m1 B");
    }
    void m2()
    {
        System.out.println("In m2 B");
    }
}
public class Test {

    public static void main(String[] args) {
        A a=new B();
        a.m2();
    }
}
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;What will be the output?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;A. In m2 B&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;B. Compile time error&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;C. Runtime error&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;B. Compile time error&lt;br&gt;
There will be compile time error.Even though we are assigning B's object to A's reference we can call only methods which are in A from A's reference.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;2. Guess the output of below program.&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;package org.arpit.java2blog;

class A
{
    void m1() throws ArrayIndexOutOfBoundsException
    {
        System.out.println("In m1 A");
    }
}
class B extends A
{
    void m1() throws IndexOutOfBoundsException
    {
        System.out.println("In m1 B");
    }
}
public class Test {

    public static void main(String[] args) {
        A a=new B();
        a.m1();
    }
}
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;What will be the output?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;A. In m1 B&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;B. Compile time error&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;C. Runtime error&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A. In m1 B&lt;br&gt;
This will work fine as ArrayIndexOutOfBoundsException and IndexOutOfBoundsException are Runtime exceptions and there is no rule for runtime exceptions while method overriding.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;3. Guess the output of below program.&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;package org.arpit.java2blog;

import java.io.IOException;

class A
{
    void m1() throws IOException
    {
        System.out.println("In m1 A");
    }
}
class B extends A
{
    void m1() throws Exception
    {
        System.out.println("In m1 B");
    }
}
public class Test {

    public static void main(String[] args) {
        A a=new B();
        try {
            a.m1();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;What will be the output?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;A. In m1 B&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;B. Compile time error&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;C. Runtime error&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;B. Compile time error&lt;br&gt;
As IOException and Exception are checked exception, so you can not broaden the scope of Exception while method overriding.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;4. What will happen in case of below program?&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;class A
{
    synchronized void m1()
    {
        System.out.println("In m1 A");
    }
    void m2()
    {
        System.out.println("In m2 A");
    }
}
&lt;/pre&gt;

&lt;p&gt;There are two threads T1 and T2. T1 is accessing m1 method. Will T2 be able to access m2 method on the same instance at the same time?&lt;/p&gt;

&lt;p&gt;Yes, T2 will be able to access m2 as it does not require lock to access m2 method./div&amp;gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;5. What will happen in case of below program?&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;class A
{
    synchronized void m1()
    {
        System.out.println("In m1 A");
    }
    synchronized void m2()
    {
        System.out.println("In m2 A");
    }
}
&lt;/pre&gt;

&lt;p&gt;There are two threads T1 and T2. T1 is accessing m1 method. Will T2 be able to access m2 method on the same instance at the same time?&lt;/p&gt;

&lt;p&gt;No, T2 will not be able to access m2 as it requires lock to access m2 method which is already taken by T1 thread.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;6. What will happen in case of below program?&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;class A
{
    synchronized static void m1()
    {
        System.out.println("In m1 A");
    }
    synchronized void m2()
    {
        System.out.println("In m2 A");
    }
}
&lt;/pre&gt;

&lt;p&gt;There are two threads T1 and T2. T1 is accessing m1 method. Will T2 be able to access m2 method on the same instance at the same time?&lt;/p&gt;

&lt;p&gt;Yes, T2 will be able to access m2 as it requires object level lock to access m2 method and T1 thread has taken class level lock.You can read more about &lt;a href="https://java2blog.com/object-level-locking-vs-class-level-locking-java/" rel="noopener noreferrer"&gt;Object level lock vs Class level lock&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;7. Guess the output of below program.&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;package org.arpit.java2blog;

import java.util.HashSet;

public class Customer {

    String name;
    int age;
    
    Customer(String name,int age)
    {
        this.name=name;
        this.age=age;
    }
    public static void main(String[] args) {
        
        Customer c1= new Customer("John",20);
        Customer c2= new Customer("John",20);
        
        HashSet&amp;lt;Customer&amp;gt; customerSet=new HashSet&amp;lt;&amp;gt;();
        customerSet.add(c1);
        customerSet.add(c2);
        System.out.println(customerSet.size());
    }

    // getters and setters
}
&lt;/pre&gt;

&lt;p&gt;Output will be 2 as we did not implement hashcode and equals method in Customer class.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;8. Guess the output of below program.&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;package org.arpit.java2blog;

public class Employee {
    String name;
    int age;
    
    public Employee(String name,int age)
    {
        this.name=name;
        this.age=age;
    }
    
    
    &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + age;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Employee other = (Employee) obj;
        if (age != other.age)
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }   
}
&lt;/pre&gt;

&lt;p&gt;Main class&lt;/p&gt;

&lt;pre&gt;package org.arpit.java2blog;

import java.util.HashMap;
import java.util.Map;

public class HashMapMain {

    public static void main(String[] args) {
        Employee emp1=new Employee("Martin",27);
        Map&amp;lt;Employee,String&amp;gt; hm=new HashMap&amp;lt;Employee,String&amp;gt;();
        hm.put(emp1, "Verified");
        emp1.setName("John");
        System.out.println(hm.get(emp1));
    }
}
&lt;/pre&gt;

&lt;p&gt;[showhide type="question8" more_text="Show Answer" less_text="Hide Answers"]&lt;br&gt;
&lt;strong&gt;Output will be null.&lt;/strong&gt;&lt;br&gt;
We have implemented Employee's hashcode and equals method using name and age attributes, so when you put emp1 as key in hashmap, it will use hashcode and equals method and will be put in HashMap.&lt;br&gt;
After putting emp1 in HashMop, we have changed name of the employee, so when you will try to retrieve element from HashMap using hm.get(emp1), you won't be able to get object which we have put earlier and it will return null.&lt;br&gt;
[/showhide]&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;9. How to decide young generation and old generation size for your application?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;It depends on nature of application.&lt;br&gt;
If you have lots of temporary objects then there will be lot of minor gc. You can provide arguments XX:NewRatio=1 to distribute 50% to young generation and 50% to old.&lt;br&gt;
By default, NewRatio=2 hence young Generation is 1/3 of total heap.&lt;br&gt;
Similarly, If you have too many long-lived objects, then you might need to increase size of tenure space by putting high value of NewRatio.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;10. What is garbage collection in java?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;Garbage collection is the process of identifying used and unused objects on java heap and removing unused object from the heap.&lt;br&gt;
A live object means object is still being referred to some part of program. Unused object means object is not being referred by any part of program and is eligible for garbage collection.&lt;br&gt;
Programmer does not have to do manual garbage collection like C or C++. Java takes care of&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;11. What are types of garbage collectors in java?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;You can see &lt;a href="https://java2blog.com/garbage-collection-java/" rel="noopener noreferrer"&gt;detailed answer over here.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;12. What is difference between Collection.synchronizedMap(map) and ConcurrentHashMap?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;When you make map thread safe by using Collection.synchronizedMap(map), it locks whole map object, but ConcurrentHashMap does not lock the whole map, it just locks part of it(Segment).&lt;br&gt;
You can read more about &lt;a href="https://www.java2blog.com/concurrenthashmap-in-java/" rel="noopener noreferrer"&gt;ConcurrentHashMap over here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;13. What will happen when you run below code&lt;/span&gt;&lt;/h3&gt;

&lt;pre&gt;package org.arpit.java2blog;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;

public class IterateMapMain {

    public static void main(String args[])
    {
        // HashMap with Country as key and capital as value
        HashMap&amp;lt;String,String&amp;gt; map=new HashMap&amp;lt;String,String&amp;gt;();
        map.put("India","Delhi");
        map.put("Japan","Tokyo");
        map.put("France","Paris");
        map.put("Russia","Moscow");

        
        // Iterating java iterator
        System.out.println("Iterating java Iterator");
        Iterator&amp;lt;String&amp;gt; countryKeySetIterator=map.keySet().iterator();
        while(countryKeySetIterator.hasNext()){
            String countryKey=countryKeySetIterator.next();
            map.put("Nepal", "KathMandu");
            System.out.println(countryKey);

        }
        System.out.println("-----------------------------");
    }

}
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;You will get below output&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Iterating java IteratorException in thread "main" java.util.ConcurrentModificationException&lt;br&gt;
at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1489)&lt;br&gt;
at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1512)&lt;br&gt;
at org.arpit.java2blog.IterateMapMain.main(IterateMapMain.java:24)&lt;br&gt;
Japan&lt;/p&gt;

&lt;p&gt;Whenever you try to change count of hashmap while iterating, it will throw java.util.ConcurrentModificationException because we call iterator.next,it checks for modCount and initial count, if it does not match it will throw ConcurrentModificationException.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;14. Write a program to print odd even numbers using threads in sequence?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;Here is the program to &lt;a href="https://www.java2blog.com/print-even-odd-numbers-threads-java/" rel="noopener noreferrer"&gt;print odd and even numbers using threads in sequence&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;15. Which design pattern you have used in your project?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;You can name few design patterns such as Singleton, Observer etc. which you might have used in your project.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;16. What is double level locking in singleton design pattern?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;Double level locking in single design pattern is used to make it thread-safe.&lt;/p&gt;

&lt;pre&gt;public static Singleton getInstance()
    { 
        if (_instance == null) { // Single Checked 
            synchronized (Singleton.class) 
            { 
                if (_instance == null)// Double checked 

                { 
                    _instance = new Singleton(); 
                }
            } 
        } return _instance; 
    }
&lt;/pre&gt;

&lt;p&gt;Let's say two threads(T1 and T2) checked for null and both reached at synchronized (Singleton.class) . T1 gets the lock and create instance of Singleton and return.Now T2 enters in synchronized block, as we have checked for null again,it will not create object again.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;17. Write a program to implement producer-consumer problem using BlockingQueue?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;You can find &lt;a href="https://www.java2blog.com/blockingqueue-in-java/" rel="noopener noreferrer"&gt;detailed answer over here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;18. Have you worked on Java 8? Can you share major changes in Java 8?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;If you have worked on Java 8, you can share major changes such Stream, lambada expression, defaults method in interface etc.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;19. Have you worked on Serialization? Can you tell difference between Serializable and Externalizable?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;You can find &lt;a href="https://www.java2blog.com/difference-between-serializable-and-externalizable-in-java/" rel="noopener noreferrer"&gt;detailed answer over here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;20. How will you detect memory leak in your application?&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;There is no simple answer to this question. You can take thread dump via JVisualVM and do the analysis in &lt;a href="https://www.eclipse.org/mat/" rel="nofollow noopener noreferrer"&gt;eclipse memory analyzer tool&lt;/a&gt;.&lt;br&gt;
That's all about &lt;a href="https://java2blog.com/java-interview-questions/" rel="noopener noreferrer"&gt;Java interview questions for 5 to 6 years experience&lt;/a&gt;.&lt;br&gt;
You may also like:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/core-java-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Core java interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-collections-interview-questions.html" rel="noopener noreferrer"&gt;Java Collections interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-string-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Java String interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/oops-interview-questions-answers-java.html" rel="noopener noreferrer"&gt;OOPs interview questions in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-multithreading-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Java Multithreading interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-exception-handling-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Exceptional handling interview questions in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-serialization-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Java Serialization interview questions in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/web-services-interview-questions.html" rel="noopener noreferrer"&gt;web services interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/restful-web-services-interview-questions.html" rel="noopener noreferrer"&gt;restful web services interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/spring-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Spring interview questions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://java2blog.com/spring-boot-interview-questions/" rel="noopener noreferrer"&gt;Spring boot interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/hibernate-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Hibernate interview questions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://java2blog.com/no-compiler-provided-environment-perhaps-running-jre-rather-jdk/" rel="noopener noreferrer"&gt;No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://java2blog.com/could-not-reserve-enough-space-for-object-heap/" rel="noopener noreferrer"&gt;Could not reserve enough space for object heap in java&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>interview</category>
    </item>
    <item>
      <title>A quick introduction to spring boot</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Fri, 19 Apr 2019 10:57:13 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/a-quick-introduction-to-spring-boot-5a7n</link>
      <guid>https://dev.to/arpitmandliya/a-quick-introduction-to-spring-boot-5a7n</guid>
      <description>&lt;p&gt;&lt;a href="https://java2blog.com/introduction-to-spring-framework/" rel="noopener noreferrer"&gt;Spring framework&lt;/a&gt; is very popular frameworks for developing various web and enterprise application. Spring has developed various projects over time and Spring Boot is one of them.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will learn Spring boot tutorial with various examples.&lt;/p&gt;

&lt;p&gt;Before learning Spring Boot application, you must have some knowledge about &lt;a href="http://www.java2blog.com/2012/08/spring-hello-world-example-in-eclipse.html" rel="noopener noreferrer"&gt;XML&lt;/a&gt; and &lt;a href="http://www.java2blog.com/2016/02/spring-java-based-configuration-example.html" rel="noopener noreferrer"&gt;Java Configuration&lt;/a&gt; in Spring framework.&lt;/p&gt;

&lt;h2&gt;What is Spring Boot?&lt;/h2&gt;

&lt;p&gt;Spring Boot is a way by which you can bootstrap or quickly create any Spring application.&lt;/p&gt;

&lt;p&gt;Here is the official definition of Spring Boot.&lt;/p&gt;

&lt;p&gt;Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".&lt;/p&gt;

&lt;p&gt;Spring Boot helps you create any Spring application in no time. It provides default configurations which help you to avoid a lot of boilerplate code which is painful to maintain.&lt;/p&gt;

&lt;h2&gt;Why Spring Boot?&lt;/h2&gt;

&lt;p&gt;Let's say you want to create &lt;a href="http://www.java2blog.com/2016/08/spring-mvc-hibernate-mysql-crud-example.html" rel="noopener noreferrer"&gt;Spring MVC Hibernate MySQL project&lt;/a&gt;.When you are working on this project, you might be confused with a lot of dependencies it requires.You might get confused with versions too.You need to configure DataSource, EntitymanagerFactory, TransactionManager etc beans. Wouldn’t it be good if Spring can do it for us automatically?&lt;/p&gt;

&lt;p&gt;yes, You guess it right. Spring Boot will take care of all above configuration which is painful to do when you want to create Spring application real quick. I have also created &lt;a href="http://www.java2blog.com/2017/05/spring-boot-hibernate-example.html" rel="noopener noreferrer"&gt;Spring boot Hibernate MySQL project&lt;/a&gt;.When you compare code between above two examples, you will get to know how amazingly Spring Boot has reduced almost half of the code.&lt;/p&gt;

&lt;p&gt;Spring Boot will take care of all above configuration which is painful to do when you want to create Spring application real quick.&lt;/p&gt;

&lt;p&gt;As I said before, Spring boot provides a lot of default configuration, hence Spring Boot will help you in creating Spring applications faster. Spring boot provides a lot of &lt;a href="https://java2blog.com/spring-boot-starters/" rel="noopener noreferrer"&gt;starter&lt;/a&gt; projects to help you create a different type of Spring application.Once you go through examples, you will understand more about starter projects.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2017%2F07%2FSpringBoot1-780x1024.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2017%2F07%2FSpringBoot1-780x1024.jpg" alt="Spring boot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Advantages of Spring Boot&lt;/h2&gt;

&lt;ul&gt;
    &lt;li&gt;It provides a lot of default configurations which help you to create Spring application faster.&lt;/li&gt;
    &lt;li&gt;It comes with embedded tomcat or jetty server, so you don't have to deploy jar.&lt;/li&gt;
    &lt;li&gt;It reduces development code by avoiding a lot of boilerplate code.&lt;/li&gt;
    &lt;li&gt;It increases productivity as you can create Spring application quickly.&lt;/li&gt;
    &lt;li&gt;It provides a lot of starter project for easy maven integration.You don't have to worry about version mismatch.&lt;/li&gt;
    &lt;li&gt;You can quickly create using sample project using &lt;a href="https://start.spring.io/" rel="noopener noreferrer"&gt;spring boot initializer&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Spring Boot tutorial examples&lt;/h2&gt;

&lt;p&gt;I have created a lot of Spring Boot examples. here is list of Spring boot tutorials.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/04/spring-boot-web-application-example.html" rel="noopener noreferrer"&gt;Spring boot web application example&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;You can create a simple hello world example using JSP as view. It will also help you understand how to override default configuration.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/05/spring-boot-hello-world-example-thymeleaf.html" rel="noopener noreferrer"&gt;Spring boot Hello world example using thymeleaf&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;You can create a simple hello world example using thymeleaf as view.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/05/spring-boot-hello-world-standalone-application.html" rel="noopener noreferrer"&gt;Spring boot standalone application&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;All about created projects are web project. In this example, we will see how to create simple standalone non web project using Spring Boot.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/04/create-restful-web-services-using-spring-boot.html" rel="noopener noreferrer"&gt;Spring boot Restful web service example&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;It is very easy to create rest web service using Spring boot rather than creating using convention way in Spring MVC.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/05/spring-boot-hibernate-example.html" rel="noopener noreferrer"&gt;Spring Boot hibernate example&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;This example will show you how to integrate Hibernate with SpringBoot. You don't have to worry about configuring DataSource, EntitymanagerFactory, TransactionManager, Spring boot will do it for you. You just need to provide required configuration in properties file.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/05/spring-boot-angularjs-example.html" rel="noopener noreferrer"&gt;Spring boot AngularJS example&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;This example will show you how to integrate AngularJS with Spring Boot.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/05/spring-boot-activemq-example.html" rel="noopener noreferrer"&gt;Spring Boot ActiveMQ example&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;This example will help you to integrate ActiveMQ with Spring Boot.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/05/spring-boot-spring-security-example.html" rel="noopener noreferrer"&gt;Spring Boot Security example&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;This example will help you to integrate Spring Security with SpringBoot.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.java2blog.com/2017/05/print-beans-loaded-spring-boot.html" rel="noopener noreferrer"&gt;How to find/print all bean loaded by Spring Boot&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;As you, Spring Boot provides a lot of default configuration. You may want to get all the beans loaded by Spring Boot behind the scene. This example will help you find all beans loaded by Spring Boot.&lt;/p&gt;

&lt;h3&gt;&lt;a href="https://java2blog.com/difference-spring-spring-boot/" rel="noopener noreferrer"&gt;Difference between Spring and Spring Boot&lt;/a&gt;&lt;/h3&gt;

&lt;h3&gt;&lt;a href="https://java2blog.com/spring-boot-interview-questions/" rel="noopener noreferrer"&gt;Spring boot interview questions&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;That's all about &lt;a href="https://java2blog.com/spring-boot-tutorial/" rel="noopener noreferrer"&gt;Spring Boot tutorial&lt;/a&gt;. I will keep adding more example to this Spring Boot tutorial.&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>spring</category>
      <category>dev</category>
    </item>
    <item>
      <title>A guide to Solid principles in java</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Tue, 16 Apr 2019 17:02:19 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/a-guide-to-solid-principles-in-java-17ne</link>
      <guid>https://dev.to/arpitmandliya/a-guide-to-solid-principles-in-java-17ne</guid>
      <description>&lt;p&gt;In this post, we will see 5 SOLID Principles in Java.&lt;/p&gt;

&lt;p&gt;Robert C. Martin gave five objected oriented design principles, and the acronym "S.O.L.I.D" is used for it. Each letter of this acronym talks about principles in &lt;a href="https://java2blog.com/core-java-tutorial-for-beginners-experienced/"&gt;Java&lt;/a&gt;. When you use all the principles of S.O.L.I.D in a combined manner, it becomes easier for you to develop software that can be managed easily. The other features of using S.O.L.I.D are:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;It avoids code smells&lt;/li&gt;
    &lt;li&gt;Quickly refractor code&lt;/li&gt;
    &lt;li&gt;Can do adaptive or agile software development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you use the principle of S.O.L.I.D in your coding, you start writing the code that is both efficient and effective.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;&lt;strong&gt;What is the meaning of S.O.L.I.D?&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;As stated above, S.O.L.I.D represents five principles of Java which are:&lt;/p&gt;

&lt;ol&gt;
    &lt;li&gt;S: Single responsibility principle&lt;/li&gt;
    &lt;li&gt;O: Open-closed principle&lt;/li&gt;
    &lt;li&gt;L: Liskov substitution principle&lt;/li&gt;
    &lt;li&gt;I: Interface segregation principle&lt;/li&gt;
    &lt;li&gt;D: Dependency inversion principle&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The article discusses each of this principle in-depth. We will start by considering the very first principle, which is single responsibility principle.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;&lt;strong&gt;Single Responsibility Principle (SRP)&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;According to the &lt;a href="https://java2blog.com/single-responsibility-principle-java/"&gt;single responsibility principle&lt;/a&gt;, there should be only one reason due to which a class has to be changed. It means that a class should have one task to do. This principle is often termed as subjective.&lt;/p&gt;

&lt;p&gt;The principle can be well understood with an example. Imagine there is a class which performs following operations.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;connected to a database&lt;/li&gt;
    &lt;li&gt;read some data from database tables&lt;/li&gt;
    &lt;li&gt;finally, write it to a file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Have you imagined the scenario? Here the class has multiple reasons to change, and few of them are the modification of file output, new data base adoption. When we are talking about single principle responsibility, we would say, there are too many reasons for the class to change; hence, it doesn't fit properly in the single responsibility principle.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;&lt;strong&gt;Open Closed Principle &lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;According to &lt;a href="https://java2blog.com/open-closed-principle-java/"&gt;open closed principle&lt;/a&gt;, entities or objects should remain open for extension, but they should stay closed for modification. To be precise, according to this principle, a class should be written in such a manner that it performs its job flawlessly without the assumption that people in the future will simply come and change it. Hence, the class should remain closed for modification, but it should have the option to get extended. Ways of extending the class include:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Inheriting from the class&lt;/li&gt;
    &lt;li&gt;Overwriting the required behaviors from the class&lt;/li&gt;
    &lt;li&gt;Extending certain behaviors of the class&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An excellent example of open closed principle can be understood with the help of browsers. Do you remember installing extensions in your chrome browser?&lt;/p&gt;

&lt;p&gt;Basic function of chrome browser is to surf different sites. Do you want to check grammar when you are writing an email using chrome browser?If yes, you can simply use Grammarly extension, it provides you grammar check on the content.&lt;/p&gt;

&lt;p&gt;This mechanism where you are adding things for increasing the functionality of the browser is an extension.  Hence, the browser is a perfect example of functionality that is open for extension but is closed for modification. In simple words, you can enhance the functionality by adding/installing plugins on your browser, but cannot build anything new.&lt;/p&gt;

&lt;p&gt;Let's take another example.&lt;br&gt;
You are using any Spring function functionality. You can obviously can not change core logic of it but you can extend Spring framework classes and create your own one.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;&lt;strong&gt;Liskov Substitution Principle &lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;Liskov substitution principle assumes q(x) to be a property, provable about entities of x which belongs to type T. Now, according to this principle, the q (y) should be now provable for objects y that belongs to type S, and the S is actually a subtype of T. Are you now confused and don't know what Liskov substitution principle actually mean? The definition of it might be a bit complex, but in fact, it is quite easy. The only thing is that every subclass or derived class should be substitutable for their parent or base class.&lt;/p&gt;

&lt;p&gt;You can say that it is a unique object-oriented principle. The principle can further be simplified by understanding this principle; a child type of a particular parent type without making any complication or blowing things up should have the ability to stand in for that parent.This principle is closely related to Liskov Substitution principle.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;&lt;strong&gt;Interface Segregation Principle&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;According to &lt;a href="https://java2blog.com/interface-segregation-principle-java/"&gt;interface segregation principle&lt;/a&gt;, a client, no matter what should never be forced to implement an interface that it does not use or the client should never be obliged to depend on any method, which is not used by them.&lt;/p&gt;

&lt;p&gt;So basically, the interface segregation principles as you prefer the interfaces, which are small but client specific instead of monolithic and bigger interface.&lt;/p&gt;

&lt;p&gt;In short, it would be bad for you to force the client to depend on a certain thing, which they don't need.&lt;/p&gt;

&lt;p&gt;Let us now again take an example to understand this.&lt;/p&gt;

&lt;p&gt;Let's take a simple example. You are implementing your own ArrayList and LinkedList in java. You create an interface called List which both classes will implement.&lt;/p&gt;

&lt;pre class="highlight java"&gt;&lt;code&gt;package org.arpit.java2blog;

public interface List&amp;lt;T&amp;gt; {
    public T get();
    public void add(T t);
    public T poll();
    public T peek();    
}
&lt;/code&gt;&lt;/pre&gt;
Let's create LinkedList class now.
&lt;pre class="highlight java"&gt;package org.arpit.java2blog;

public class LinkedList implements List{

    @Override
    public Integer get() {
        // Implement this method
        return null;
    }

    @Override
    public void add(Integer t) {
        // Implement this method
    }

    @Override
    public Integer poll() {
        // Implement this method
        return null;
    }

    @Override
    public Integer peek() {
        // Implement this method
        return null;
    }
}
&lt;/pre&gt;

&lt;p&gt;Let's create ArrayList class now.&lt;/p&gt;

&lt;pre class="highlight java"&gt;package org.arpit.java2blog;

public class ArrayList implements List{

    @Override
    public Integer get() {
        // Implement this method
        return null;
    }

    @Override
    public void add(Integer t) {
        // Implement this method
    }

    @Override
    public Integer poll() {
        // ArrayList does not require this method
        return null;
    }

    @Override
    public Integer peek() {
        // ArrayList does not require this method
        return null;
    }
}

&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Do you see the problem&lt;/strong&gt;, even though you do not require poll and peek method in ArrayList, we have implemented them.&lt;br&gt;
&lt;strong&gt;The correct solution for above problem will be:&lt;/strong&gt;&lt;br&gt;
Create another interface called Deque which will have peek and poll method.&lt;/p&gt;

&lt;pre class="highlight java"&gt;package org.arpit.java2blog;

public interface Deque&amp;lt;T&amp;gt; {
    public T poll();
    public T peek();    
}
&lt;/pre&gt;

&lt;p&gt;And remove peek and poll from list interface.&lt;/p&gt;

&lt;pre class="highlight java"&gt;package org.arpit.java2blog;

public interface List&amp;lt;T&amp;gt; {
    public T get();
    public void add(T t);   
}
&lt;/pre&gt;

&lt;p&gt;Let's change LinkedList class now.&lt;/p&gt;

&lt;pre class="highlight java"&gt;package org.arpit.java2blog;

public class LinkedList implements List,Deque{

    @Override
    public Integer get() {
        // Implement this method
        return null;
    }

    @Override
    public void add(Integer t) {
        // Implement this method
    }

    @Override
    public Integer poll() {
        // Implement this method
        return null;
    }

    @Override
    public Integer peek() {
        // Implement this method
        return null;
    }
}
&lt;/pre&gt;

&lt;p&gt;Let's change ArrayList class now.&lt;/p&gt;

&lt;pre class="highlight java"&gt;package org.arpit.java2blog;

public class ArrayList implements List{

    @Override
    public Integer get() {
        // Implement this method
        return null;
    }

    @Override
    public void add(Integer t) {
        // Implement this method
    }
}
&lt;/pre&gt;

&lt;p&gt;As you can see, we have seggregated two interface to achieve required functionality.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;&lt;strong&gt;Dependency Inversion Principle&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;According to this, dependency inversion principle, entities should depend only on abstractions but not on concretions. According to it, the high-level module must never rely on any low-level module but should depend on abstractions. Let us again understand it through another practical example.&lt;/p&gt;

&lt;p&gt;You go to a local store to buy something, and you decide to pay for it by using your debit card. So, when you give your card to the clerk for making the payment, the clerk doesn't bother to check what kind of card you have given. Even if you have given a Visa card, he will not put out a Visa machine for swiping your card. The type of credit card or debit card that you have for paying does not even matter; they will simply swipe it. So, in this example, you can see that both you and the clerk are dependent on the credit card abstraction and you are not worried about the specifics of the card. This is what a dependency inversion principle is.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;&lt;strong&gt;Wrap Up &lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;I hope that now you know the basic definition of all the five components of S.O.L.I.D, which are single responsibility principle, open, closed principle, Liskov substitution principle, interface segregation principle, and dependency inversion. So, basically, whenever you write code, you have to keep these core principle in your mind and actually, to be honest, you have to take these principles as your base map while writing those codes to make it efficient and effective.&lt;/p&gt;

&lt;p&gt;The management of the code written by using these principles is also an easy task to do. Using this principle initially in your coding might look odd but you need to practice writing your codes using these principles, and gradually it will become a part of you. And then, the code that you have written can be easily modified, extended, refactored, or tested without facing any problem according to the requirement that you meet. So practice this principle whenever possible to make your coding better.&lt;br&gt;
Source: &lt;a href="https://java2blog.com/single-responsibility-principle-java/"&gt;Solid principles in java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may also like:&lt;br&gt;
&lt;a href="https://java2blog.com/xms-xmx-parameter-java/"&gt;xms and xmx parameter in java&lt;/a&gt;&lt;br&gt;
&lt;a href="https://java2blog.com/java-reached-end-file-parsing/"&gt;Java reached end of file while parsing&lt;/a&gt;&lt;br&gt;
&lt;a href="https://java2blog.com/java-lang-numberformatexception/"&gt;NumberFormatException in java&lt;/a&gt;&lt;br&gt;
&lt;a href="https://java2blog.com/filenotfoundexception-java/"&gt;FileNotFoundException in java&lt;/a&gt;&lt;br&gt;
&lt;a href="https://java2blog.com/java-isnumeric/"&gt;Check if number is numeric in java&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>design</category>
      <category>programming</category>
      <category>solid</category>
    </item>
    <item>
      <title>Top 100+ data structures and algorithms interview questions in java</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Sat, 13 Apr 2019 19:46:07 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/top-40-data-structures-and-algorithms-interview-questions-in-java-56kj</link>
      <guid>https://dev.to/arpitmandliya/top-40-data-structures-and-algorithms-interview-questions-in-java-56kj</guid>
      <description>&lt;p&gt;I have been posting &lt;a href="https://java2blog.com/data-structures-java/" rel="noopener"&gt;data structure&lt;/a&gt; and algorithms interview questions on various topics such as Array, Queue, Stack, Binary tree, LinkedList, String, Number, ArrayList, etc. So I am consolidating a list of programs to create an index post. I will keep adding links to this post whenever I add new programs. These are frequently asked Data Structure and algorithm interview questions.&lt;/p&gt;

&lt;p&gt;If you want to practice and improve data structure and algorithm programs, this post will be very helpful to you. I will recommend you to try it yourself first and then check the solution.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Stack&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aYZ7_WVj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/09/Stack.png" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-4004" src="https://res.cloudinary.com/practicaldev/image/fetch/s--aYZ7_WVj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/09/Stack.png" alt="Stack" width="530" height="396"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 1:  Implement a stack using array.&lt;/h4&gt;

&lt;p&gt;You need to implement Stack using array. You need to write push and pop methods to demonstrate Stack behavior(Last In First Out).&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;:&lt;a href="http://www.java2blog.com/implement-stack-using-array-in-java.html" rel="noopener noreferrer"&gt; Java Program to implement stack using array.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 2: Implement a stack using Linked List :&lt;/h4&gt;

&lt;p&gt;You need to implement Stack using Linked List. You need to write push and pop methods to demonstrate Stack behavior(Last In First Out).&lt;br&gt;
&lt;b&gt;Solution  &lt;/b&gt;: &lt;a href="http://www.java2blog.com/implement-stack-using-linked-list-in-java.html" rel="noopener noreferrer"&gt;Java Program to implement stack using Linked List&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 3:  Implement a stack using two queues .&lt;/h4&gt;

&lt;p&gt;You need to use two queues to implement stack behavior.You need to write push and pop methods to demonstrate Stack behavior(Last In First Out).&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;:&lt;a href="http://www.java2blog.com/implement-stack-using-two-queues-in-java.html" rel="noopener noreferrer"&gt; Java Program to implement stack using two queues&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 4 : Sort an stack using another stack&lt;/h4&gt;

&lt;p&gt;You need to sort an stack using another stack. You can use push and pop operation of stack to do so,&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/sort-stack-using-another-stack.html" rel="noopener noreferrer"&gt;Sort a stack using another stack.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Queue&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0FKhZKcJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/09/Queue.png" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-4003" src="https://res.cloudinary.com/practicaldev/image/fetch/s--0FKhZKcJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/09/Queue.png" alt="Queue" width="674" height="301"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 5:  Implement Queue using Array in java.&lt;/h4&gt;

&lt;p&gt;You need to use array to implement queue.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;:&lt;a href="https://java2blog.com/implement-queue-using-array-in-java/" rel="noopener noreferrer"&gt; Implement Queue using Array in java&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 6:  Implement a stack using two queues .&lt;/h4&gt;

&lt;p&gt;You need to use Linked list to implement queue.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;:&lt;a href="https://java2blog.com/implement-queue-using-linked-list-in-java/" rel="noopener noreferrer"&gt; Java Program to implement queue using linked list&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Linked List&lt;/span&gt;&lt;/h2&gt;




&lt;h4&gt;Question 7 : Implement singly linked list in java.&lt;/h4&gt;

&lt;p&gt;You need to implement singly linked list data structures.You need to write simple program to demonstrate insert , delete operations.&lt;br&gt;
&lt;a href="https://4.bp.blogspot.com/-4VowsytKKXw/VcWkmtC4WSI/AAAAAAAAD2E/0PmX9VUjHhQOotuRV5Ne3mpdJ3eHfWkTwCPcB/s1600/LinkedListWithoutLoop.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_bFfGBuT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://4.bp.blogspot.com/-4VowsytKKXw/VcWkmtC4WSI/AAAAAAAAD2E/0PmX9VUjHhQOotuRV5Ne3mpdJ3eHfWkTwCPcB/s640/LinkedListWithoutLoop.jpg" width="640" height="42"&gt;&lt;/a&gt;&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/implement-singly-linked-list-in-java.html" rel="noopener noreferrer"&gt;Java program to implement singly linked list in java.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 8: How to reverse linked list in java.&lt;/h4&gt;

&lt;p&gt;You need to write iterative and recursive solution to reverse linked list.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;&lt;a href="http://www.java2blog.com/how-to-reverse-linked-list-in-java.html" rel="noopener noreferrer"&gt;: Java program to reverse linked list in java.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 9: How to find middle element of linked list.&lt;/h4&gt;

&lt;p&gt;You need to write java program to find middle element of linked list in most optimize way.&lt;br&gt;
&lt;a href="https://3.bp.blogspot.com/-foKjwd459OI/VcWoTxo6SUI/AAAAAAAAD2Y/dLcoqXhuAAYla_z_glpCDiXOjlxAzPS2gCPcB/s1600/LinkedListWithMiddleElement.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XH-KgoaP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://3.bp.blogspot.com/-foKjwd459OI/VcWoTxo6SUI/AAAAAAAAD2Y/dLcoqXhuAAYla_z_glpCDiXOjlxAzPS2gCPcB/s640/LinqkedListWithMiddleElement.jpg" width="640" height="42"&gt;&lt;/a&gt;&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://www.code2master.com/java/find-middle-element-linked-list-one-scan/" rel="noopener noreferrer"&gt;Java program to find middle element of linked list&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 10 : How to find nth element from end of linked list .&lt;/h4&gt;

&lt;p&gt;You need to write java program to find nth  element of linked list in most optimize way.&lt;br&gt;
In question 6, Node 7 is 3rd from last of linked list.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;:&lt;a href="http://www.java2blog.com/find-nth-element-from-end-of-linked-list.html" rel="noopener noreferrer"&gt; How to find nth element from end of linked list.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 11 : How to detect a loop in linked list. If linked list has loop, find the start node for the loop.&lt;/h4&gt;

&lt;p&gt;You need to write a java program to detect whether any loop exists in linked list and if loop exists , you need to find start node for the linked list.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/how-to-detect-loop-in-linkedlist-in.html" rel="noopener noreferrer"&gt;How to detect loop in linked list&lt;/a&gt;.&lt;br&gt;
&lt;a href="http://www.java2blog.com/find-start-node-of-loop-in-linkedlist.html" rel="noopener noreferrer"&gt;How to find start node of loop in linked list.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 12: How to check if linked list is palindrome or not?&lt;/h4&gt;

&lt;p&gt;A palindrome is a word, phrase, number, or other sequence of symbols or elements that reads the same forward or reversed. For example: 12121 is palindrome as it reads same forward or reversed. madam is also a palindrome . So we need write java programs to check if linked list is palindrome or not.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/how-to-check-if-linked-list-is.html" rel="noopener noreferrer"&gt;Java program to check if linked list is palindrome.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 13 :  Find intersection of two linked lists?&lt;/h4&gt;

&lt;p&gt;Given two &lt;a href="https://java2blog.com/implement-singly-linked-list-in-java/" rel="noopener"&gt;singly linked lists&lt;/a&gt;, find if two linked lists intersect. If they intersect, find intersection point.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kgoBFtXc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2018/08/LinkedListIntersection.jpg" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-6348" src="https://res.cloudinary.com/practicaldev/image/fetch/s--kgoBFtXc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2018/08/LinkedListIntersection.jpg" alt="" width="711" height="401"&gt;&lt;/a&gt;&lt;br&gt;
Solution  : &lt;a href="https://java2blog.com/intersection-two-linked-lists/" rel="noopener"&gt;Intersection of two linked list&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 14 :  How to reverse a linked list in pairs?&lt;/h4&gt;

&lt;p&gt;You need to write a java program to reverse linked list in pairs.&lt;br&gt;
&lt;a href="https://1.bp.blogspot.com/-8N1scpgMXSQ/Vv7OSOBFbAI/AAAAAAAAEbI/4H2jGeVaK0Au9iyJ-ykRpTlgwJzft5kwQCPcB/s1600/ReverseLinkedListInPairs.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---k8ERBmZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://1.bp.blogspot.com/-8N1scpgMXSQ/Vv7OSOBFbAI/AAAAAAAAEbI/4H2jGeVaK0Au9iyJ-ykRpTlgwJzft5kwQCPcB/s640/ReverseLinkedListInPairs.png" width="640" height="250"&gt;&lt;/a&gt;&lt;br&gt;
Solution  : &lt;a href="http://www.java2blog.com/java-program-to-reverse-linked-list-in.html" rel="noopener noreferrer"&gt;Java program to reverse linked list in pair.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 15 :  Implement Doubly linked list in java?&lt;/h4&gt;

&lt;p&gt;You need to write a java program to implement doubly linked list in java.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mz0q_U_X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/09/DoublyLinkedList.png" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-3900" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mz0q_U_X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/09/DoublyLinkedList.png" alt="Doubly Linked List in java" width="793" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution  : &lt;a href="https://java2blog.com/doubly-linked-list-java/" rel="noopener"&gt;Doubly Linked List in java&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Array&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--30XglUZx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/09/Array.png" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-4002" src="https://res.cloudinary.com/practicaldev/image/fetch/s--30XglUZx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/09/Array.png" alt="Array" width="595" height="234"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 16 : Write java Program to Find Smallest and Largest Element in an Array.&lt;/h4&gt;

&lt;p&gt;You are given an integer array containing 1 to n but one of the number from 1 to n in the array is missing. You need to provide an optimum solution to find the missing number. Number can not be repeated in the arry.&lt;br&gt;
For example:&lt;/p&gt;

&lt;pre class=""&gt;int[] arr1={7,5,6,1,4,2};
Missing numner : 3
int[] arr2={5,3,1,2};
Missing numner : 4&lt;/pre&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/java-program-to-find-smallest-and-largest-number-in-array/" rel="noopener noreferrer"&gt;Java Program to Find Smallest and Largest Element in an Array&lt;/a&gt;



&lt;h4&gt;Question 17 : Find missing number in the array.&lt;/h4&gt;


You are given an integer array containing 1 to n but one of the number from 1 to n in the array is missing. You need to provide optimum solution to find the missing number. Number cannot be repeated in the arry.
For example:
&lt;pre class=""&gt;int[] arr1={7,5,6,1,4,2};
Missing numner : 3
int[] arr2={5,3,1,2};
Missing numner : 4&lt;/pre&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/java-program-to-find-missing-number-in-array.html" rel="noopener noreferrer"&gt;Find missing number in the array.&lt;/a&gt;



&lt;h4&gt;Question 18 : Search an element in rotated and sorted array.&lt;/h4&gt;
You are given an sorted and rotated array as below:
&lt;pre class=""&gt;int arr[]={16,19,21,25,3,5,8,10};&lt;/pre&gt;
If you note that array is sorted and rotated. You need to search an element in above array in o(log n) time complexity.
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/search-element-in-sorted-and-rotated-array-java.html" rel="noopener noreferrer"&gt;Search element in rotated and sorted array&lt;/a&gt;



&lt;h4&gt;Question 19 : Find minimum element in a sorted and rotated array.&lt;/h4&gt;
You are given an sorted and rotated array as below:
&lt;pre class=""&gt;int arr[]={16,19,21,25,3,5,8,10};
Minimum element in the array : 3
&lt;/pre&gt;

&lt;p&gt;If you note that array is sorted and rotated. You need to i an element in above array in o(log n) time complexity.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/find-minimum-element-in-sorted-and-rotated-array-java/" rel="noopener noreferrer"&gt;Find minimum element in a sorted and rotated array&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 20: Find second largest number in an array&lt;/h4&gt;

&lt;p&gt;You are given an sorted and rotated array as below:&lt;br&gt;
&lt;b&gt;For example:&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;int[] arr1={7,5,6,1,4,2};
Second largest element in the array : 6&lt;/pre&gt;
&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="http://www.java2blog.com/find-second-largest-number-in-array-java.html" rel="noopener noreferrer"&gt;java program to find second largest number in an array&lt;/a&gt;.




&lt;h4&gt;Question 21 : Find the number occurring odd number of times in an array&lt;/h4&gt;
You are given a array of integer. All numbers occur even number of times except one. You need to find the number which occurs odd number of time. You need to solve it with o(n) time complexity and o(1) space complexity.
For example:
&lt;pre&gt;int array[] = new int[]{20, 40, 50, 40, 50, 20, 30, 30, 50, 20, 40, 40, 20};
Number which occurs odd number of times is : 50&lt;/pre&gt;


&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="http://www.java2blog.com/find-number-occurring-odd-number-of-times-in-array.html" rel="noopener noreferrer"&gt;java program to find number occurring odd number of times in an array&lt;/a&gt;.






&lt;h4&gt;Question 22 : Find minimum number of platforms required for railway station&lt;/h4&gt;

&lt;p&gt;&lt;span&gt;You are given arrival and departure time of trains reaching to a particular station. You need to find minimum number of platforms required to accommodate the trains at any point of time.&lt;/span&gt;&lt;/p&gt;



&lt;b&gt;For example:&lt;/b&gt;
&lt;pre&gt;arrival[] = {1:00, 1:40, 1:50, 2:00, 2:15, 4:00} 
departure[] = {1:10, 3:00, 2:20, 2:30, 3:15, 6:00}
No. of platforms required in above scenario = 4&lt;/pre&gt;
Please note that arrival time is in chronological order.



&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="http://www.java2blog.com/minimum-number-of-platforms-required-for-railway-station.html" rel="noopener noreferrer"&gt;Find minimum number of platforms required for railway station&lt;/a&gt;.




&lt;h4&gt;Question 23 : Find a Pair Whose Sum is Closest to zero in Array&lt;/h4&gt;

Given array of +ve and -ve integers ,we need to find a pair whose sum is closed to Zero in Array.

&lt;b&gt;For example:&lt;/b&gt;

&lt;pre&gt;array[]={1,3,-5,7,8,20,-40,6};
The pair whose sum is closest to zero :  -5 and 6&lt;/pre&gt;
&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="http://www.java2blog.com/find-pair-whose-sum-is-closest-to-zero-in-array.html" rel="noopener noreferrer"&gt;Find a Pair Whose Sum is Closest to zero in Array in java&lt;/a&gt;.



&lt;h4&gt;Question 24 : Given a sorted array and a number x, find the pair in array whose sum is closest to x&lt;/h4&gt;

Given a sorted array, we need to find a pair whose sum is closed to number X in Array.
&lt;b&gt;For example:&lt;/b&gt;
&lt;pre class=""&gt;array[]={-40,-5,1,3,6,7,8,20};
The pair whose sum is closest to 5 :  1 and 3&lt;/pre&gt;

&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="http://www.java2blog.com/given-sorted-array-number-x-find-pair-closest-to-x-array.html" rel="noopener noreferrer"&gt;Find a Pair Whose Sum is Closest to X in Array in java&lt;/a&gt;.



&lt;h4&gt;Question 25 : Find all pairs of elements from an array whose sum is equal to given number&lt;/h4&gt;

Given a  array,we need to find all pairs whose sum is equal to number X.
&lt;b&gt;For example:&lt;/b&gt;
&lt;pre class=""&gt;array[]={ -40, -5, 1, 3, 6, 7, 8, 20 };
Pair of elements whose sum is equal to 15 :  7, 8 and -5, 20&lt;/pre&gt;

&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="http://www.java2blog.com/find-all-pairs-elements-from-array-sum-equals-given-number-java.html" rel="noopener noreferrer"&gt;Find all pairs of elements from an array whose sum is equal to given number &lt;/a&gt;.




&lt;h4&gt;Question 26: Given an array of 0’s and 1’s in random order, you need to separate 0’s and 1’s in an array.&lt;/h4&gt;

&lt;b&gt;For example:&lt;/b&gt;
&lt;pre class=""&gt;arr[] = {0,1,0,0,1,1,1,0,1}
Array after separating 0 and 1 numbers :
{0,0,0,0,1,1,1,1,1}&lt;/pre&gt;

&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/separate-0s-and-1s-in-array/" rel="noopener"&gt;Separate 0s and 1s in array&lt;/a&gt;.





&lt;h4&gt;Question 27 : Separate odd and even numbers in an array&lt;/h4&gt;
Given an array of integers, you need to segregate odd and even numbers in an array.
Please note: Order of elements can be changed.

&lt;b&gt;For example:&lt;/b&gt;
&lt;pre class=""&gt;arr[] = {12, 17, 70, 15, 22, 65, 21, 90}
Array after separating odd and even numbers :
{12, 90, 70, 22, 15, 65, 21, 17}&lt;/pre&gt;

&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/separate-odd-and-even-numbers-in-array/" rel="noopener"&gt;Separate 0s and 1s in array&lt;/a&gt;.






&lt;h4&gt;Question 28 : Given an array containing zeroes, ones and twos only. Write a function to sort the given array in O(n) time complexity.&lt;/h4&gt;

&lt;b&gt;For example:&lt;/b&gt;
&lt;pre class=""&gt;Input :
[1, 2, 2, 0, 0, 1, 2, 2, 1]
 
Output :
[0, 0, 1, 1, 1, 2, 2, 2, 2]
&lt;/pre&gt;



&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/sort-array-of-0s-1s-and-2s/" rel="noopener"&gt;Sort an array of 0s, 1s and 2s&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 29 : Find local minima in array&lt;/h4&gt;

&lt;p&gt;A local minima is less than its neighbours&lt;/p&gt;

&lt;p&gt;&lt;b&gt;For example:&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;Input :

int [] arr = {10, 5, 3, 6, 13, 16, 7};
Output: 2
 
int []arr = {11,12,13,14};
Output: 11
 
int []arr = {10};
Output: 10
 
int []arr = {8,6};
Output: 6
&lt;/pre&gt;




&lt;h4&gt;Question 30 : Sliding window maximum in java&lt;/h4&gt;

&lt;p&gt;Given an Array of integers and an Integer k, Find the maximum element of from all the contiguous subarrays of size K.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;For example:&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;Input :
Input : int[] arr = {2,6,-1,2,4,1,-6,5}
int k = 3
output : 6,6,4,4,4,5
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/sliding-window-maximum-java/" rel="noopener"&gt;Find the local minima in array&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 31 : Count number of occurrences (or frequency) of each element in a sorted array&lt;/h4&gt;

&lt;p&gt;Given a Sorted Array of integers containing duplicates. Find the frequency of every unique element present in the array.&lt;br&gt;
Frequency is defined as the number of occurrence of any element in the array.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;Input :
Input:
int[] arr = {1, 1, 1, 3, 3, 4, 5, 5, 6, 6};
Output:
Frequency of 1 is : 3
Frequency of 3 is : 2
Frequency of 4 is : 1
Frequency of 5 is : 2
Frequency of 6 is : 2
&lt;/pre&gt;



&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/count-occurences-frequency-each-element-sorted-array/" rel="noopener"&gt;Count number of occurrences (or frequency) of each element in a sorted array&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 32 : Find subarrays with given sum in an array.&lt;/h4&gt;

&lt;p&gt;Given an Array of non negative Integers and a number. You need to print all the starting and ending indices of Subarrays having their sum equal to the given integer.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;Input :
Input-int[] arr = {2, 3, 6, 4, 9, 0, 11};
int num = 9
Output-
starting index : 1, Ending index : 2
starting index : 5, Ending index : 5
starting index : 5, Ending index : 6
&lt;/pre&gt;



&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/find-subarrays-given-sum-array/" rel="noopener"&gt;Find subarrays with given sum in an array&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 33 : Find peak element in the array.&lt;/h4&gt;

&lt;p&gt;Peak Element is the element of the array which is GREATER THAN / EQUAL TO its neighbours, that is, for an element at i th index, the neighbour elements at index i-1 &amp;amp; i+1 must be greater than equal to element at i th position.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/find-subarrays-given-sum-array/" rel="noopener"&gt;Find peak element in the array&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 34 : Find leaders in an array.&lt;/h4&gt;

&lt;p&gt;We need to print all the leaders present in the array. Element is the leader if it is greater than right side of elements.&lt;/p&gt;

&lt;pre&gt;arr[]={14, 12, 70, 15, 99, 65, 21, 90}
Here 99 and 90 are leader elements
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;For example:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/find-leaders-in-array/" rel="noopener"&gt;Find leaders in an array&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 35 : Count 1’s in sorted Binary Array.&lt;/h4&gt;

&lt;p&gt;Print number of 1’s in a given sorted Binary Array.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;Input :
int[] arr = {0,0,0,1,1,1,1};
output : 4
int[] arr = {0,0,1};
output : 1
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/count-1s-sorted-binary-array/" rel="noopener"&gt;Count 1’s in sorted Binary Array&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 36 : Find first repeating element in an array of integers.&lt;/h4&gt;

&lt;p&gt;Find the first repeating element in array of integers.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;Input :
Input: array[] = {10, 7, 8, 1, 8, 7, 6}
Output: 7 [7 is the first element actually repeats]
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/find-first-repeating-element-array-integers/" rel="noopener"&gt;Find first repeating element in an array of integers&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 37 : Check if Array Elements are Consecutive.&lt;/h4&gt;

&lt;p&gt;Given an array, we need to check if array contains consecutive elements.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;Input: array[] = {5, 3, 4, 1, 2}
Output: true
As array contains consecutive elements from 1 to 5Input: array[] = {47, 43, 45, 44, 46}
Output: true
As array contains consecutive elements from 43 to 47Input: array[] = {6, 7, 5, 6}
Output: false
As array does not contain consecutive elements.
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/check-array-elements-consecutive/" rel="noopener"&gt;Check if Array Elements are Consecutive&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 38 : Permutations of array in java.&lt;/h4&gt;

&lt;p&gt;Given array of distinct integers, print all permutations of the array.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;array : [10, 20, 30]

Permuations are :

[10, 20, 30]
[10, 30, 20]
[20, 10, 30]
[20, 30, 10]
[30, 10, 20]
[30, 20, 10]
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/permutations-array-java/" rel="noopener"&gt;Permutations of array in java&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 39 : Rotate an array by K positions.&lt;/h4&gt;

&lt;p&gt;&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;N=6 and k=2
If Arr[] = {1, 2, 3, 4, 5, 6} and k=2
then rotated array will be  {5, 6, 1, 2,  3,  4}
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/rotate-array-by-k-positions/" rel="noopener"&gt;Rotate an array by K positions&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 40 : Stock Buy Sell to Maximize Profit.&lt;/h4&gt;

&lt;p&gt;Given an array of integers representing stock price on single day, find max profit that can be earned by 1 transaction.&lt;br&gt;
So you need to find pair (buyDay,sellDay) where buyDay &amp;lt; = sellDay and it should maximise the profit.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;int arr[]={14, 12, 70, 15, 99, 65, 21, 90};
Max profit can be gain by buying at 1th day(0 based indexing) and sell at 4th day.
Max profit = 99-12 =87
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/stock-buy-sell-to-maximize-profit/" rel="noopener"&gt;Stock Buy Sell to Maximize Profit&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 41 : Find maximum difference between two elements such that larger element appears after the smaller number.&lt;/h4&gt;

&lt;p&gt;Given array of integers, find Maximum difference between two elements such that larger element appears after the smaller number&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;int arr[]={14, 12, 70, 15, 95, 65, 22, 30};
Max Difference =95-12 = 83
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/maximum-difference-between-two-elements-in-array/" rel="noopener"&gt;Maximum difference between two elements such that larger element appears after the smaller number&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 42 : Search in a row wise and column wise sorted matrix.&lt;/h4&gt;

&lt;p&gt;Given row wise and column wise sorted matrix ,we need to search element with minimum time complexity.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/search-in-row-wise-and-column-wise-sorted-matrix/" rel="noopener"&gt;Search in a row wise and column wise sorted matrix&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 43 : Largest sum contiguous subarray.&lt;/h4&gt;

&lt;p&gt;Largest sum contiguous subarray is the task of finding the contiguous subarray within a one-dimensional array of numbers which has the largest sum.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;for the sequence of values −2, 1, −3, 4, −1, 2, 1, −5, 4; the contiguous subarray with the largest sum is 4, −1, 2, 1, with sum 6
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/largest-sum-contiguous-subarray/" rel="noopener"&gt;Largest sum contiguous subarray&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 44 : Find the Contiguous Subarray with Sum to a Given Value in an array.&lt;/h4&gt;

&lt;p&gt;Given an array of positive integer and given value X, find Contiguous sub array whose sum is equal to X.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;arr[]={14, 12, 70, 15, 99, 65, 21, 90}; 
X =97.
Sum found between index 1 to 3
Elements are 12, 17 and 15
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/find-contiguous-subarray-with-sum-to-given-value-array/" rel="noopener"&gt;Find the Contiguous Subarray with Sum to a Given Value in an array&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 45 : Longest Common Prefix in an array of Strings in java.&lt;/h4&gt;

&lt;p&gt;Given an array of positive integer and given value X, find Contiguous sub array whose sum is equal to X.&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;String[] strArr={"java2blog","javaworld","javabean","javatemp"};
So Longest common prefix in above String array will be “java” as all above string starts with “java”.
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/longest-common-prefix-in-array-of-strings-java/" rel="noopener"&gt;Longest Common Prefix in an array of Strings in java&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Question 46 : Find all subsets of set (power set) in java.&lt;/h4&gt;

&lt;p&gt;Given a set of distinct integers, arr, return all possible subsets (the power set).&lt;br&gt;
&lt;b&gt;For example :&lt;/b&gt;&lt;/p&gt;

&lt;pre class=""&gt;Input: nums = [1,2,3]
Output:
[
[3],
[1],
[2],
[1,2,3],
[1,3],
[2,3],
[1,2],
[]
]
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Solution : &lt;/b&gt;&lt;a href="https://java2blog.com/longest-common-prefix-in-array-of-strings-java/" rel="noopener"&gt;Find all subsets of set in java&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;String&lt;/span&gt;&lt;/h2&gt;




&lt;h4&gt;Question 47 : How to reverse a String in java? Can you write a program without using any java inbuilt methods?&lt;/h4&gt;




&lt;b&gt;Solution:&lt;/b&gt; There are many ways to do it, some of them are:
&lt;ul&gt;
    &lt;li&gt;Using for loop&lt;/li&gt;
    &lt;li&gt;Using recursion&lt;/li&gt;
    &lt;li&gt;Using StringBuffer&lt;/li&gt;
&lt;/ul&gt;
Please refer to the solution at &lt;a href="http://www.java2blog.com/java-program-to-reverse-string.html" rel="noopener"&gt;reverse a String in java&lt;/a&gt;







&lt;h4&gt;Question 48 : Write a java program to check if two Strings are anagram in java?&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Solution: &lt;/strong&gt;Two string are anagrams if they have same characters but in different order. For example: Angel and Angle are anagrams&lt;br&gt;
There are few ways to check if Strings are anagrams. Some of them are:&lt;/p&gt;

&lt;ol&gt;
    &lt;li&gt;Using String methods&lt;/li&gt;
    &lt;li&gt;Using array.sort&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Check solution at &lt;a href="http://www.java2blog.com/check-if-two-strings-are-anagrams-in-java-example-program.html"&gt;check if two Strings are anagram in java.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 49 : Write a program to check if String has all unique characters in java?&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Solution: &lt;/strong&gt;Here are some ways to check if String contains all unique characters&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;By using HashSet&lt;/li&gt;
    &lt;li&gt;Using indexOf and lastIndexOf methods of String&lt;/li&gt;
    &lt;li&gt;By Using ascii value of characters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please refer to complete solution at &lt;a href="http://www.java2blog.com/check-if-string-has-all-unique-characters-in-java.html" rel="noopener"&gt;check if String has all unique characters&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 50 : How to check if one String is rotation of another String in java?&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Solution: Let's&lt;/strong&gt; say you want to check whether str1 and str2 is rotation of one another or not.&lt;/p&gt;

&lt;ol&gt;
    &lt;li&gt;Create a new String with str3= str1 + str1&lt;/li&gt;
    &lt;li&gt;Check if str3 &lt;a href="http://www.java2blog.com/2016/05/java-string-contains-example.html" rel="noopener"&gt;contains&lt;/a&gt; str2 or not.&lt;/li&gt;
    &lt;li&gt;if str3 &lt;a href="http://www.java2blog.com/2016/05/java-string-contains-example.html" rel="noopener"&gt;contains&lt;/a&gt; str2 then str2 is rotation of str1 else it is not&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can find complete solution at &lt;a href="http://www.java2blog.com/check-if-one-string-is-rotation-of-another-java.html" rel="noopener"&gt;check if one String is rotation of another in java&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 51 : How to find duplicate characters in String in java?&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Solution:  &lt;/strong&gt;Here is a solution to find duplicate characters in String.&lt;/p&gt;

&lt;ol&gt;
    &lt;li&gt;Create a &lt;a href="http://www.java2blog.com/hashmap-in-java-with-examples.html" rel="noopener"&gt;HashMap&lt;/a&gt; and character of String will be inserted as key and its count as value.&lt;/li&gt;
    &lt;li&gt;If &lt;a href="http://www.java2blog.com/hashmap-in-java-with-examples.html" rel="noopener"&gt;Hashamap&lt;/a&gt; already contains char,increase its count by 1, else put char in HashMap.&lt;/li&gt;
    &lt;li&gt;If value of Char is more than 1, that means it is duplicate character in that String.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;span&gt;Please refer to solution at&lt;a href="http://www.java2blog.com/2016/05/find-duplicate-characters-in-string-java.html" rel="noopener"&gt; program to find duplicate characters in a String&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;




&lt;h4&gt;Question 52 : Find first non repeated character in String in java?&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Solution: &lt;/strong&gt;There are may ways to find it.&lt;br&gt;
Some of them are:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Using &lt;a href="https://java2blog.com/linkedhashmap-in-java-with-example/"&gt;LinkedHashMap&lt;/a&gt;
&lt;/li&gt;
    &lt;li&gt;Using indexOf and lastIndexOf methods.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please find complete solution at &lt;a href="http://www.java2blog.com/find-first-non-repeated-character-in.html" rel="noopener"&gt;find first non repeated character in  a String&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 53 : Find all substrings of String in java?&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Java program to find all &lt;a href="https://java2blog.com/find-all-substrings-of-string-in-java/"&gt;substrings&lt;/a&gt; of a String.&lt;br&gt;
For example: If input is "abb"  then output should be "a", "b","b", "ab", "bb", "abb"&lt;br&gt;
We will use String class's subString method to find all subString.&lt;br&gt;
Please refer to complete solution at &lt;a href="http://www.java2blog.com/2015/08/find-all-substrings-of-string-in-java.html" rel="noopener"&gt;find all subStrings of String.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 54 : Find length of String without using any inbuilt method in java?&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; You can use try catch block for catching StringIndexOutOfBoundException and when this exception aries, you can simply return i(Index at which you will get the exception)&lt;br&gt;
Please refer to complete solution at &lt;a href="http://www.java2blog.com/find-length-of-string-without-using.html" rel="noopener"&gt;find length of String without inbuilt methods&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 55 : Write a program to print all permutations of String in java?&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Take out first character of String and insert into different places of permutations of remaining String recursively. Please find complete solution at &lt;a href="http://www.java2blog.com/find-all-permutations-of-string-in-java.html"&gt;how to find all permutations of String in java&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Binary Tree&lt;/span&gt;&lt;/h2&gt;




&lt;h4&gt;Question 56 : How can you traverse binary tree?&lt;/h4&gt;

&lt;p&gt;There are three ways to traverse binary tree.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/binary-tree-preorder-traversal-in-java.html" rel="noopener noreferrer"&gt;PreOrder&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/binary-tree-inorder-traversal-in-java.html" rel="noopener noreferrer"&gt;InOrder&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;
&lt;a href="http://www.java2blog.com/binary-tree-postorder-traversal-in-java.html" rel="noopener noreferrer"&gt;PostOrder&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;Question 57 : Write an algorithm to do level order traversal of binary tree?&lt;/h4&gt;

&lt;p&gt;You need to write java program to do level order traversal of binary tree. You can use queue data structure to do level order traversal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://4.bp.blogspot.com/-9ZfyN1HIsU4/U8pBOBFEVBI/AAAAAAAADQU/hzEVUv0l_qg70nnqRlCyQWqaFTvuJaFMgCPcB/s1600/LevelOrderTraversal.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--odtMK60H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://4.bp.blogspot.com/-9ZfyN1HIsU4/U8pBOBFEVBI/AAAAAAAADQU/hzEVUv0l_qg70nnqRlCyQWqaFTvuJaFMgCPcB/s400/LevelOrderTraversal.jpg" width="400" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/binary-tree-level-order-traversal-in.html" rel="noopener noreferrer"&gt;Level order traversal of binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 58 :  Write an algorithm to do spiral order traversal of binary tree?&lt;/h4&gt;

&lt;p&gt;You need to write java program to do spiral level order traversal of binary tree&lt;/p&gt;

&lt;p&gt;&lt;a href="https://2.bp.blogspot.com/-ngOLkuERRkE/U9B9A6wKGGI/AAAAAAAADRo/PeIrrdiac-YJTRBsU57hnq8VYPIxS6IXQCPcB/s1600/SpiralTraversalOfBinaryTree.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tyN3G2OV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://2.bp.blogspot.com/-ngOLkuERRkE/U9B9A6wKGGI/AAAAAAAADRo/PeIrrdiac-YJTRBsU57hnq8VYPIxS6IXQCPcB/s400/SpiralTraversalOfBinaryTree.jpg" width="400" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/spiralzigzag-level-order-traversal-of.html" rel="noopener noreferrer"&gt;Sprial order or zigzag traversal of binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 59 : How can you print leaf nodes of binary tree?&lt;/h4&gt;

&lt;p&gt;You need to write java program to print all leaf nodes of binary tree.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://2.bp.blogspot.com/-PYnM66CqEHU/U8pr_oueEQI/AAAAAAAADQw/ZcOIEJaLK8QFvYnigQPnOzpxeastoJ_wgCPcB/s1600/updatedBinaryTree.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aiOFhwLw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://2.bp.blogspot.com/-PYnM66CqEHU/U8pr_oueEQI/AAAAAAAADQw/ZcOIEJaLK8QFvYnigQPnOzpxeastoJ_wgCPcB/s320/updatedBinaryTree.jpg" width="320" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Leaf nodes for above binary tree will be 5 , 30 , 55 ,70&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;:&lt;a href="http://www.java2blog.com/how-to-print-leaf-nodes-of-binary-tree.html" rel="noopener noreferrer"&gt; Print leaf nodes of binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 60 : How to count leaf nodes of binary tree.&lt;/h4&gt;

&lt;p&gt;You need to write java program to count leaf nodes of binary tree.&lt;br&gt;
Count of Leaf nodes for binary tree used in Question 15 are &lt;b&gt;5&lt;/b&gt;.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/program-to-count-leaf-nodes-in-binary.html" rel="noopener noreferrer"&gt;Count leaf nodes of binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 61 : How to print all paths from root to leaf in binary tree.&lt;/h4&gt;

&lt;p&gt;You need to write a program to print all paths from root to leaf.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://3.bp.blogspot.com/-Wt5jULjXxHA/U90abF_QhlI/AAAAAAAADS4/RYdIEhU_WponN6jy2MbgoFeUBKNcnsRQwCPcB/s1600/printPathsToRootToLeafInBinaryTree.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UViQ4k9k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://3.bp.blogspot.com/-Wt5jULjXxHA/U90abF_QhlI/AAAAAAAADS4/RYdIEhU_WponN6jy2MbgoFeUBKNcnsRQwCPcB/s400/printPathsToRootToLeafInBinaryTree.jpg" width="400" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/print-all-paths-from-root-to-leaf-in.html" rel="noopener noreferrer"&gt;Print all paths from root to leaf in binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 62 : How to find level of node in binary tree&lt;/h4&gt;

&lt;p&gt;Given a node, you need to find level of a node. For example : Level of node will 3 for node 70 used in Question 14.&lt;br&gt;
&lt;b&gt;Solution&lt;/b&gt;: &lt;a href="http://www.java2blog.com/get-level-of-node-in-binary-tree-in-java.html" rel="noopener noreferrer"&gt;Find level of node in binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 63 : How to find maximum element in binary tree.&lt;/h4&gt;

&lt;p&gt;You need to write a java program to find maximum element in binary tree.&lt;br&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/find-maximum-element-binary-tree-java/" rel="noopener noreferrer"&gt;Find maximum element in binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 64 : How to find lowest common ancestor(LCA) in binary tree.&lt;/h4&gt;

&lt;p&gt;You need to write a program to find LCA in binary tree.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://3.bp.blogspot.com/-_gLipfU6NNs/Vw9BZZCQAAI/AAAAAAAAEdQ/YnmE_P_ff18tnZ8_4zO3KeMBhumpNWGCgCPcB/s1600/LCA.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6uSqx5XG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://3.bp.blogspot.com/-_gLipfU6NNs/Vw9BZZCQAAI/AAAAAAAAEdQ/YnmE_P_ff18tnZ8_4zO3KeMBhumpNWGCgCPcB/s400/LCA.png" width="400" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Solution&lt;/b&gt;: &lt;a href="http://www.java2blog.com/lowest-common-ancestor-of-binary-tree.html" rel="noopener noreferrer"&gt;Program to find LCA in binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 65 : How to do boundary traversal of binary tree.&lt;/h4&gt;

&lt;p&gt;Write a java program to do boundary traversal of binary tree as shown in below image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://3.bp.blogspot.com/-zdIDNbOoJRI/Vw6RKLnFplI/AAAAAAAAEcQ/5IRJuqrNmDE8MIDmxNp2he4cE05QP5BNwCPcB/s1600/BoundaryTraversal.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hXuSFwe9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://3.bp.blogspot.com/-zdIDNbOoJRI/Vw6RKLnFplI/AAAAAAAAEcQ/5IRJuqrNmDE8MIDmxNp2he4cE05QP5BNwCPcB/s400/BoundaryTraversal.png" width="400" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution : &lt;a href="http://www.java2blog.com/boundary-traversal-of-binary-tree-in.html" rel="noopener noreferrer"&gt;Boundary traversal of binary tree.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 66 : How to print vertical sum of binary tree?&lt;/h4&gt;

&lt;p&gt;You need to find sum of nodes which lies in same column.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://2.bp.blogspot.com/-gFPNh_dhSSI/Vjz4_mGN2YI/AAAAAAAAEIQ/GAL1gwuyiGAuIADiaBEp0LfAV03o5d_2ACPcB/s1600/verticalSum.jpg.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fOZc6B5e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://2.bp.blogspot.com/-gFPNh_dhSSI/Vjz4_mGN2YI/AAAAAAAAEIQ/GAL1gwuyiGAuIADiaBEp0LfAV03o5d_2ACPcB/s400/verticalSum.jpg.png" width="400" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution : &lt;a href="http://www.java2blog.com/vertical-sum-of-binary-tree-in-java.html" rel="noopener noreferrer"&gt;How to print vertical sum of binary tree&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 67 : Count subtrees with Sum equal to target in binary tree?&lt;/h4&gt;

&lt;p&gt;Given a &lt;a href="https://java2blog.com/binary-tree-in-java/" rel="noopener"&gt;Binary tree&lt;/a&gt; and an integer. You need to find the number of subtrees having the sum of all of its nodes equal to given Integer, that is, Target sum.&lt;/p&gt;

&lt;p&gt;Solution : &lt;a href="http://www.java2blog.com/vertical-sum-of-binary-tree-in-java.html" rel="noopener noreferrer"&gt;Count subtrees with Sum equal to target in binary tree&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Binary Search tree&lt;/span&gt;&lt;/h2&gt;




&lt;h4&gt;Question 68 : What is binary search tree?&lt;/h4&gt;

&lt;p&gt;Binary search tree is a special type of &lt;a href="http://www.java2blog.com/binary-tree-in-java.html" rel="noopener noreferrer"&gt;binary tree&lt;/a&gt; which have following properties.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Nodes which are smaller than root will be in left subtree.&lt;/li&gt;
    &lt;li&gt;Nodes which are greater than root will be right subtree.&lt;/li&gt;
    &lt;li&gt;It should not have duplicate nodes&lt;/li&gt;
    &lt;li&gt;Both left and right subtree also should be binary search tree.&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;Question 69 : Can you write algorithm to insert a node in binary search tree.&lt;/h4&gt;



&lt;p&gt;&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/binary-search-tree-in-java/" rel="noopener noreferrer"&gt;Insert node in binary search tree&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 70 : Can you write algorithm to delete a node in binary search tree.&lt;/h4&gt;

&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/how-to-delete-node-from-binary-search-tree-java/" rel="noopener noreferrer"&gt;Delete node in binary search tree&lt;/a&gt;




&lt;h4&gt;Question 71 :  How can you find minimum and maximum elements in binary search tree?&lt;/h4&gt;

&lt;b&gt;Solution &lt;/b&gt;: Leftmost and rightmost nodes of binary search tree are minimum and maximum nodes respectively

&lt;a href="https://java2blog.com/find-minimum-and-maximum-elements-binary-search-tree-java/" rel="noopener noreferrer"&gt;Minimum and maximum elements in binary search tree&lt;/a&gt;.





&lt;h4&gt;Question 72 : How to find lowest common ancestor(LCA) in binary search tree.&lt;/h4&gt;
You need to write a program to find LCA in binary search tree.

&lt;a href="https://3.bp.blogspot.com/-_gLipfU6NNs/Vw9BZZCQAAI/AAAAAAAAEdQ/YnmE_P_ff18tnZ8_4zO3KeMBhumpNWGCgCPcB/s1600/LCA.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6uSqx5XG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://3.bp.blogspot.com/-_gLipfU6NNs/Vw9BZZCQAAI/AAAAAAAAEdQ/YnmE_P_ff18tnZ8_4zO3KeMBhumpNWGCgCPcB/s400/LCA.png" width="400" height="282"&gt;&lt;/a&gt;
&lt;b&gt;Solution&lt;/b&gt;: &lt;a href="http://www.java2blog.com/lowest-common-ancestor-of-binary-search.html" rel="noopener noreferrer"&gt;Program to find LCA in binary search tree.&lt;/a&gt;







&lt;h4&gt;Question 73 : Find inorder successor in a Binary search Tree&lt;/h4&gt;
You need to write a program to find inorder successor in a Binary search tree.

&lt;b&gt;Solution&lt;/b&gt;: &lt;a href="https://java2blog.com/inorder-successor-binary-search-tree/" rel="noopener"&gt;Inorder Successor in a Binary Search Tree&lt;/a&gt;



&lt;h4&gt;Question 74 : Convert sorted array to balanced BST&lt;/h4&gt;
&lt;b&gt;Solution&lt;/b&gt;: &lt;a href="https://java2blog.com/convert-sorted-array-to-balanced-binary-search-tree/" rel="noopener"&gt;Convert sorted sorted array to balanced BST&lt;/a&gt;



&lt;h4&gt;Question 75 : Convert sorted Linked List to balanced BST&lt;/h4&gt;
&lt;b&gt;Solution&lt;/b&gt;: &lt;a href="https://java2blog.com/convert-sorted-linkedlist-to-balanced-bst/" rel="noopener"&gt;Convert sorted Linked List to balanced BST&lt;/a&gt;



&lt;h4&gt;Question 76 : Check if a binary tree is binary search tree or not in java&lt;/h4&gt;
&lt;b&gt;Solution&lt;/b&gt;: &lt;a href="https://java2blog.com/check-if-binary-tree-is-binary-search-tree-java/" rel="noopener"&gt;Check if a binary tree is binary search tree or not in java&lt;/a&gt;
&lt;h2&gt;&lt;span&gt;Sorting&lt;/span&gt;&lt;/h2&gt;






&lt;h4&gt;Question 77 : Write an algorithm to implement bubble sort?&lt;/h4&gt;


&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/implement-bubble-sort-in-java/" rel="noopener noreferrer"&gt;Bubble sort in java&lt;/a&gt;





&lt;h4&gt;Question 78 : Write an algorithm to implement insertion sort sort?&lt;/h4&gt;


&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/implement-insertion-sort-in-java/" rel="noopener noreferrer"&gt;Insertion sort in java&lt;/a&gt;





&lt;h4&gt;Question 79 : Write an algorithm to implement selection sort sort?&lt;/h4&gt;


&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/selection-sort-in-java/" rel="noopener noreferrer"&gt;Selection sort in java&lt;/a&gt;




&lt;h4&gt;Question 80 : Can you write algorithm for merge sort and also do you know complexity of merge sort?&lt;/h4&gt;

&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/implement-merge-sort-in-java/" rel="noopener noreferrer"&gt;Merge sort in java&lt;/a&gt;





&lt;h4&gt;Question 81 : Do you know how to implement Heap sort?&lt;/h4&gt;


&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/heap-sort-in-java/" rel="noopener noreferrer"&gt;implement Heap sort in java&lt;/a&gt;




&lt;h4&gt;Question 82 : Implement quick sort in java?&lt;/h4&gt;

&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/quick-sort-in-java/" rel="noopener noreferrer"&gt;implement Quick sort in java&lt;/a&gt;




&lt;h4&gt;Question 83 : Implement shell sort in java?&lt;/h4&gt;

&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/shell-sort-in-java/" rel="noopener noreferrer"&gt;implement Shell sort in java&lt;/a&gt;




&lt;h4&gt;Question 84 : Implement Counting sort in java?&lt;/h4&gt;

&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="https://java2blog.com/counting-sort-in-java/" rel="noopener noreferrer"&gt;implement Counting sort in java&lt;/a&gt;





&lt;h4&gt;Question 85 : What is binary search? Can you write an algorithm to find an element in sorted array using binary search?&lt;/h4&gt;


&lt;b&gt;Solution &lt;/b&gt;:&lt;a href="https://java2blog.com/binary-search-java/" rel="noopener noreferrer"&gt;Binary search algorithm in java&lt;/a&gt;


&lt;h2&gt;&lt;span&gt;Graph&lt;/span&gt;&lt;/h2&gt;



&lt;h4&gt;Question 86 : Write algorithm to do depth first search in a graph.&lt;/h4&gt;
&lt;b&gt;Solution &lt;/b&gt;: &lt;a href="http://www.java2blog.com/depth-first-search-in-java.html" rel="noopener noreferrer"&gt;Depth first search in java&lt;/a&gt;




&lt;h4&gt;Question 87 : Write algorithm to do breadth first search in a graph.&lt;/h4&gt;
Solution : &lt;a href="http://www.java2blog.com/breadth-first-search-in-java.html" rel="noopener noreferrer"&gt;breadth first search in java&lt;/a&gt;





&lt;h4&gt;Question 88 : Explain Dijkstra algorithm from source to all other vertices.&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PJEIJZCo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/11/DijkstraInitialize.png" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-4477" src="https://res.cloudinary.com/practicaldev/image/fetch/s--PJEIJZCo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2017/11/DijkstraInitialize.png" alt="DijkstraInitialize" width="700" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution : &lt;a href="https://java2blog.com/dijkstra-java/" rel="noopener noreferrer"&gt;Dijkstra’s algorithm in java&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 89 : Explain Bellman Ford algorithm to find shortest distance&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SEcdJUGv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2018/11/bellman-Ford1.jpg" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-6895" src="https://res.cloudinary.com/practicaldev/image/fetch/s--SEcdJUGv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2018/11/bellman-Ford1.jpg" alt="Bellman Ford" width="301" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution : &lt;a href="https://java2blog.com/bellman-ford-algorithm-java/" rel="noopener noreferrer"&gt;Bellman ford algorithm in java&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 90 : Explain Kruskal's algorithm for finding minimum spanning tree&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qGtSPctN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2018/12/Kruskals1.png" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-7013" src="https://res.cloudinary.com/practicaldev/image/fetch/s--qGtSPctN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2018/12/Kruskals1.png" alt="Kruskals1" width="366" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution : &lt;a href="https://java2blog.com/kruskals-algorithm-minimum-spanning-tree/" rel="noopener noreferrer"&gt;Kruskal's algorithm&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Dynamic Programming&lt;/span&gt;&lt;/h2&gt;




&lt;h4&gt;Question 91 : Given two String, find longest common substring.&lt;/h4&gt;

&lt;p&gt;Solution: &lt;a href="https://java2blog.com/longest-common-substring-java/" rel="noopener"&gt;Longest common substring in java&lt;/a&gt;.&lt;/p&gt;




&lt;h4&gt;Question 92 : Given two Strings A and B. Find the length of the Longest Common Subsequence (LCS) of the given Strings.&lt;/h4&gt;

&lt;p&gt;Solution: &lt;a href="https://java2blog.com/longest-common-subsequence-java/" rel="noopener"&gt;Longest common subsequence in java&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 93 : Given a matrix, we need to count all paths from top left to bottom right of MxN matrix. You can either move down or right.&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vrTs9BGh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2018/08/MatrixPaths.jpg" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-6359" src="https://res.cloudinary.com/practicaldev/image/fetch/s--vrTs9BGh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://java2blog.com/wp-content/uploads/2018/08/MatrixPaths.jpg" alt="Matrix paths" width="271" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Solution: &lt;a href="https://java2blog.com/count-paths-top-left-bottom-right-mxn-matrix/" rel="noopener"&gt;Count all paths in matrix&lt;/a&gt;&lt;/p&gt;




&lt;h4 class="title single-title entry-title"&gt;Question 94 : Edit Distance Problem in java&lt;/h4&gt;

&lt;p&gt;Given two strings string1 and string2, String1 is to be converted into String2 with the given operations available in the minimum number of steps. Using any one of the given operations contributes to the increment of steps by one.&lt;/p&gt;

&lt;p&gt;Allowed Operations are :&lt;br&gt;
(i) &lt;strong&gt;Remove&lt;/strong&gt; : This operation allows the Removal any one character from String.&lt;br&gt;
(ii) &lt;strong&gt;Insert&lt;/strong&gt; : This operation allows the Insertion of one character at any spot in the String.&lt;br&gt;
(iii) &lt;strong&gt;Replace&lt;/strong&gt; : This operation allows the replacement of any one character in the string with&lt;br&gt;
any other character.&lt;/p&gt;

&lt;p&gt;Solution: &lt;a href="https://java2blog.com/edit-distance-problem/" rel="noopener"&gt;Edit distance problem in java&lt;/a&gt;.&lt;/p&gt;




&lt;h4 class="title single-title entry-title"&gt;Question 95: Coin change problem in java&lt;/h4&gt;

&lt;p&gt;Given an Amount to be paid and the currencies to pay with. There is infinite supply of every currency using combination of which, the given amount is to be paid. Print the number of ways by which the amount can be paid.&lt;/p&gt;

&lt;p&gt;Solution: &lt;a href="https://java2blog.com/coin-change-problem-java/" rel="noopener"&gt;Coin change problem in java&lt;/a&gt;&lt;/p&gt;




&lt;h4 class="title single-title entry-title"&gt;Question 96 : Minimum number of jumps to reach last index&lt;/h4&gt;

&lt;p&gt;Solution: &lt;a href="https://java2blog.com/minimum-number-jumps-reach-last-index/"&gt;Minimum number of jumps to reach last index&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;&lt;span&gt;Miscellaneous&lt;/span&gt;&lt;/h2&gt;




&lt;h4&gt;Question 97 : What is an algorithm and how to calculate complexity of algorithms.&lt;/h4&gt;

&lt;p&gt;Solution : &lt;a href="http://www.java2blog.com/introduction-to-complexity-of-algorithm.html" rel="noopener noreferrer"&gt;How to calculate Complexity of algorithm&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 98 : Implement trie data structure in java.&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NRH_Mbiz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://4.bp.blogspot.com/-GNWc5KUMGYc/WAskP-EHFKI/AAAAAAAAEz4/8yikxc2niYgyqH0FWFafq5UTp_kUK6O5ACLcB/s1600/TrieDataStructureImpl.png" class="article-body-image-wrapper"&gt;&lt;img class="aligncenter size-full wp-image-4004" src="https://res.cloudinary.com/practicaldev/image/fetch/s--NRH_Mbiz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://4.bp.blogspot.com/-GNWc5KUMGYc/WAskP-EHFKI/AAAAAAAAEz4/8yikxc2niYgyqH0FWFafq5UTp_kUK6O5ACLcB/s1600/TrieDataStructureImpl.png" alt="Stack" width="530" height="396"&gt;&lt;/a&gt;&lt;br&gt;
Solution : &lt;a href="https://java2blog.com/trie-data-structure-in-java/" rel="noopener noreferrer"&gt;Implement trie data structure in java.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 99 : Count Factorial Trailing Zeroes in java.&lt;/h4&gt;

&lt;p&gt;Solution : &lt;a href="https://java2blog.com/count-factorial-trailing-zeroes-java/" rel="noopener noreferrer"&gt;Count Factorial Trailing Zeroes in java&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 100 : Largest Rectangular Area in a Histogram.&lt;/h4&gt;

&lt;p&gt;Solution : &lt;a href="https://java2blog.com/largest-rectangular-area-histogram/" rel="noopener noreferrer"&gt;Count Largest Rectangular Area in a Histogram&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 101 : Check for balanced parentheses in an expression in java.&lt;/h4&gt;

&lt;p&gt;Solution : &lt;a href="https://java2blog.com/check-for-balanced-parentheses-in-expression-java/" rel="noopener noreferrer"&gt;check for balanced parentheses in an expression in java.&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;Question 102 : What is Memoization.&lt;/h4&gt;

&lt;p&gt;Solution :&lt;br&gt;
Memoization ensures that method does not execute more than once for same inputs by storing the results in the data structure(Usually Hashtable or HashMap or Array).&lt;br&gt;
&lt;a href="https://java2blog.com/memoization-example-java/" rel="noopener noreferrer"&gt;Memoization example in java&lt;/a&gt;&lt;br&gt;
Source:&lt;a href="https://java2blog.com/data-structure-and-algorithm-interview-questions-in-java/" rel="noopener noreferrer"&gt;data structure and algorithm interview questions in java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is all about questions on data structure and algorithm interview questions. Please do comment if you want to add any new questions to above list.&lt;br&gt;
You may also like:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/core-java-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Core java interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-collections-interview-questions.html" rel="noopener noreferrer"&gt;Java Collections interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-string-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Java String interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/oops-interview-questions-answers-java.html" rel="noopener noreferrer"&gt;OOPs interview questions in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-multithreading-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Java Multithreading interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-exception-handling-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Exceptional handling interview questions in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/java-serialization-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Java Serialization interview questions in java&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/web-services-interview-questions.html" rel="noopener noreferrer"&gt;web services interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/restful-web-services-interview-questions.html" rel="noopener noreferrer"&gt;restful web services interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/spring-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Spring interview questions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://java2blog.com/spring-boot-interview-questions/" rel="noopener noreferrer"&gt;Spring boot interview questions&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.java2blog.com/hibernate-interview-questions-and-answers.html" rel="noopener noreferrer"&gt;Hibernate interview questions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;





</description>
      <category>java</category>
      <category>algorithms</category>
      <category>practice</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Java 8 Optional: A way to avoid NullPointerException</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Thu, 11 Apr 2019 17:26:58 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/java-8-optional-a-way-to-avoid-nullpointerexception-10g1</link>
      <guid>https://dev.to/arpitmandliya/java-8-optional-a-way-to-avoid-nullpointerexception-10g1</guid>
      <description>&lt;p&gt;In this post, we will see about Java 8 optional.&lt;/p&gt;

&lt;p&gt;Did you ever get &lt;a href="https://java2blog.com/java-lang-nullpointerexception/" rel="noopener noreferrer"&gt;&lt;strong&gt;NullPointerException&lt;/strong&gt;&lt;/a&gt; as Java developer? If you are experienced Java developer, you might have got NullPointerException at some point of time.&lt;br&gt;
You might agree that NullPointerException is pain for novice or expert &lt;a href="https://java2blog.com/core-java-tutorial-for-beginners-experienced/" rel="noopener noreferrer"&gt;core java&lt;/a&gt; developer. You have to put a lot of defensive code in case you want to avoid NullPointerException.&lt;br&gt;
Let's see with the help of an example.&lt;/p&gt;

&lt;pre&gt;package org.arpit.java2blog;

public class Employee {
    private String name;
    private int age;
    
    public Employee(String name, int age) {
        super();
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
}
&lt;/pre&gt;

&lt;p&gt;Create a main class named "JavaFindEmployeeMain.java"&lt;/p&gt;

&lt;pre&gt;package org.arpit.java2blog;
 
import java.util.ArrayList;
import java.util.List;
 
public class JavaFindEmployeeMain {
    
    public static void main(String[] args)
    {
        List&amp;lt;Employee&amp;gt; employeeList = createEmployeeList();
        Employee employee = findEmployee(employeeList,"Adam");
        System.out.println("Employee name: "+employee.getName());
    }
    
    public static Employee findEmployee(List&amp;lt;Employee&amp;gt; employeeList,String name)
    {
        for(Employee e:employeeList)
        {
            if(e.getName().equalsIgnoreCase(name))
            {
                return e;
            }
        }
        return null;
    }
    public static List&amp;lt;Employee&amp;gt; createEmployeeList()
    {
        List&amp;lt;Employee&amp;gt; employeeList=new ArrayList&amp;lt;&amp;gt;();
        
        Employee e1=new Employee("John",21);
        Employee e2=new Employee("Martin",22);
        Employee e3=new Employee("Mary",31);
        Employee e4=new Employee("Stephan",18);
        Employee e5=new Employee("Gary",26);
        
        employeeList.add(e1);
        employeeList.add(e2);
        employeeList.add(e3);
        employeeList.add(e4);
        employeeList.add(e5);
        
        return employeeList;
        
    }
}
&lt;/pre&gt;

&lt;p&gt;When you run above program, you will get below output:&lt;/p&gt;

&lt;p&gt;Exception in thread "main" java.lang.NullPointerException&lt;br&gt;
at org.arpit.java2blog.JavaOptionalMain.main(JavaOptionalMain.java:12)&lt;/p&gt;

&lt;p&gt;As you can see, "Adam" is not present in employeeList, that's why we are getting NullPointerException here.&lt;/p&gt;

&lt;p&gt;Do you see the issue here? We forgot to check null when we tried to find employee in the list. This occurs more often when you call library function and it returns null and you forget to check it.&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Java 8 Optional&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;You can use Optional to solve this problem. You can change "JavaOptionalMain" as below.&lt;/p&gt;

&lt;pre&gt;package org.arpit.java2blog;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
 
public class JavaOptionalMain {
    
    public static void main(String[] args)
    {
        List&amp;lt;Employee&amp;gt; employeeList = createEmployeeList();
        Optional&amp;lt;Employee&amp;gt; employeeOpt = findEmployee(employeeList,"Adam");
        if(employeeOpt.isPresent())
        {
            Employee employee = employeeOpt.get();
            System.out.println("Employee name: "+employee.getName());
        }
        else
        {
            System.out.println("There is no employee with name Adam");
        }
    }
    
    public static Optional&amp;lt;Employee&amp;gt; findEmployee(List&amp;lt;Employee&amp;gt; employeeList,String name)
    {
        for(Employee e:employeeList)
        {
            if(e.getName().equalsIgnoreCase(name))
            {
                return Optional.of(e);
            }
        }
        return Optional.empty();
    }
    public static List&amp;lt;Employee&amp;gt; createEmployeeList()
    {
        List&amp;lt;Employee&amp;gt; employeeList=new ArrayList&amp;lt;&amp;gt;();
        
        Employee e1=new Employee("John",21);
        Employee e2=new Employee("Martin",22);
        Employee e3=new Employee("Mary",31);
        Employee e4=new Employee("Stephan",18);
        Employee e5=new Employee("Gary",26);
        
        employeeList.add(e1);
        employeeList.add(e2);
        employeeList.add(e3);
        employeeList.add(e4);
        employeeList.add(e5);
        
        return employeeList;
    }
}
&lt;/pre&gt;

&lt;p&gt;When you run above program, you will get below output:&lt;/p&gt;

&lt;p&gt;There is no employee with name Adam&lt;/p&gt;

&lt;p&gt;You might think that you could have handled null in JavaFindEmployeeMain as well but when you return Optional from method, it means that missing value can be expected from method.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2018%2F05%2FOptional.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjava2blog.com%2Fwp-content%2Fuploads%2F2018%2F05%2FOptional.jpg" alt="Optional Java 8"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Ways to create Optional&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;There are multiple ways to create Optional.&lt;/p&gt;

&lt;h3&gt;Empty Optional&lt;/h3&gt;

&lt;p&gt;You can create empty optional object using static factory method "empty"&lt;/p&gt;

&lt;pre&gt;Optional&amp;lt;Employee&amp;gt; optCar = Optional.empty();
&lt;/pre&gt;

&lt;h3&gt;Optional from a non-null value&lt;/h3&gt;

&lt;p&gt;You can create Optional from non-null value using static factory method "of"&lt;/p&gt;

&lt;pre&gt;Optional&amp;lt;Employee&amp;gt; optCar = Optional.of(employee);
&lt;/pre&gt;

&lt;p&gt;If employee is null then above method will throw NullPointerException.&lt;/p&gt;

&lt;h3&gt;Optional from null or non-null value&lt;/h3&gt;

&lt;p&gt;You can create Optional from null or non null value using static factory method "ofNullable"&lt;/p&gt;

&lt;pre&gt;Optional&amp;lt;Employee&amp;gt; optCar = Optional.ofNullable(employee);
&lt;/pre&gt;




&lt;h2&gt;&lt;span&gt;Getting value from Optional&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;You can use get() method to retrieve value from Optional but it is least safe. If value is not present then it will throw NoSuchElementException, so you need to make sure you call isPresent() method before you call get() method.&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Check value in Optional&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;You can check if there is value wrapped inside Optional using isPresent method.&lt;/p&gt;

&lt;pre&gt;    public static void main(String[] args)
    {
            List&amp;lt;Employee&amp;gt; employeeList = createEmployeeList();
        Optional&amp;lt;Employee&amp;gt; employeeOpt = findEmployee(employeeList,"Adam");
        if(employeeOpt.isPresent())
        {
            Employee employee = employeeOpt.get();
            System.out.println("Employee name: "+employee.getName());
        }
        else
        {
            System.out.println("There is no employee with name Adam");
        }
    }
&lt;/pre&gt;




&lt;h2&gt;&lt;span&gt;Conditional action in Optional&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;You can use ifPresent method to execute action if value is present in Optional.&lt;br&gt;
Change main method in JavaOptionalMain as below&lt;/p&gt;

&lt;pre&gt;      
    public static void main(String[] args)
    {
        List&amp;lt;Employee&amp;gt; employeeList = createEmployeeList();
        Optional&amp;lt;Employee&amp;gt; employeeOpt1 = findEmployee(employeeList,"Adam");
        Optional&amp;lt;Employee&amp;gt; employeeOpt2 = findEmployee(employeeList,"John");
        
        employeeOpt1.ifPresent((employee)-&amp;gt;System.out.println("Employee name: "+employee.getName()+" found in list"));
        employeeOpt2.ifPresent((employee)-&amp;gt;System.out.println("Employee name: "+employee.getName()+" found in list"));

    }
&lt;/pre&gt;

&lt;p&gt;When you run this program, you will get below output:&lt;/p&gt;

&lt;p&gt;Employee name: Dummy&lt;br&gt;
Employee name: John found in list&lt;/p&gt;

&lt;p&gt;As you can see here, if employee name present in the list, then only we are printing employee name else it does not perform any action.&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Default value in Optional using orElse&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;You can return default value in case there is no value in Optional using orElse method.&lt;br&gt;
Change main method in JavaOptionalMain as below&lt;/p&gt;

&lt;pre&gt;     
    public static void main(String[] args)
    {
        List&amp;lt;Employee&amp;gt; employeeList = createEmployeeList();
        Optional&amp;lt;Employee&amp;gt; employeeOpt = findEmployee(employeeList,"Adam");
        Employee employee1 = employeeOpt.orElse(new Employee("Dummy",0));
        System.out.println("Employee name: "+employee1.getName());
        
        Optional&amp;lt;Employee&amp;gt; employeeOpt2 = findEmployee(employeeList,"Martin");
        Employee employee2= employeeOpt2.orElse(new Employee("Dummy",0));
        System.out.println("Employee name: "+employee2.getName());
        
    }
&lt;/pre&gt;

&lt;p&gt;When you run this program, you will get below output:&lt;/p&gt;

&lt;p&gt;Employee name: Dummy&lt;br&gt;
Employee name: Martin&lt;/p&gt;

&lt;p&gt;Please note that even if value is present in Optional, default object will be crerted.&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Default value in Optional using orElseGet&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;orElseGet is lazy counter part of orElse.It takes &lt;a href="https://java2blog.com/java-8-supplier-example/" rel="noopener noreferrer"&gt;supplier&lt;/a&gt; as parameter and will be called only if value is not present in Optional.&lt;br&gt;
Change main method in JavaOptionalMain as below&lt;/p&gt;

&lt;pre&gt;    
    public static void main(String[] args)
    {
        List&amp;lt;Employee&amp;gt; employeeList = createEmployeeList();
        Optional&amp;lt;Employee&amp;gt; employeeOpt = findEmployee(employeeList,"Adam");
        Employee employee1 = employeeOpt.orElseGet(()-&amp;gt;new Employee("Dummy",0));
        System.out.println("Employee name: "+employee1.getName());
        
        Optional&amp;lt;Employee&amp;gt; employeeOpt2 = findEmployee(employeeList,"Martin");
        Employee employee2 = employeeOpt2.orElseGet(()-&amp;gt;new Employee("Dummy",0));
        System.out.println("Employee name: "+employee2.getName());
        
    }
&lt;/pre&gt;

&lt;p&gt;When you run this program, you will get below output:&lt;/p&gt;

&lt;p&gt;Employee name: Dummy&lt;br&gt;
Employee name: Martin&lt;/p&gt;




&lt;h2&gt;&lt;span&gt;Throwing exception from Optional&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;You can use orElseThrow to throw exception in case Optional is empty. It is similar to get() method but in this case, you can choose to throw any Exception rathar than NoSuchMethodException.&lt;br&gt;
Change main method in JavaOptionalMain as below&lt;/p&gt;

&lt;pre&gt;    public static void main(String[] args)
    {
        List&amp;lt;Employee&amp;gt; employeeList = createEmployeeList();
        Optional&amp;lt;Employee&amp;gt; employeeOpt = findEmployee(employeeList,"Adam");
        Employee employee1 = employeeOpt.orElseThrow(() -&amp;gt; new RuntimeException("Employee not found"));
        System.out.println("Employee name: "+employee1.getName());
        
        Optional&amp;lt;Employee&amp;gt; employeeOpt2 = findEmployee(employeeList,"Martin");
        Employee employee2 = employeeOpt2.orElseThrow(() -&amp;gt; new RuntimeException("Employee not found"));
        System.out.println("Employee name: "+employee2.getName());
        
    }
&lt;/pre&gt;

&lt;h2&gt;&lt;span&gt;Use of Optional in Java 8 APIs&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;There are lot of uses of Optional in Java 8 APIs.Let me provide you one example.&lt;br&gt;
Stream.findFirst() method returns an Optional with the first element of this stream, or an empty Optional if the stream is empty.&lt;/p&gt;

&lt;p&gt;That's all about Optional in &lt;a href="https://java2blog.com/java-8-tutorial/" rel="noopener noreferrer"&gt;Java 8&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy learning!!&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>java8</category>
    </item>
    <item>
      <title>How to learn java programming</title>
      <dc:creator>arpitmandliya</dc:creator>
      <pubDate>Thu, 11 Apr 2019 17:13:48 +0000</pubDate>
      <link>https://dev.to/arpitmandliya/how-to-learn-java-programming-1jp7</link>
      <guid>https://dev.to/arpitmandliya/how-to-learn-java-programming-1jp7</guid>
      <description>&lt;p&gt;Java is one of the most used programming languages in the world for developing the desktop application and web application. It has completed 22 years in the programming world.&lt;/p&gt;

&lt;p&gt;In this post, we will see how to learn java programming in depth and in the most efficient way.&lt;/p&gt;

&lt;p&gt;Java has a huge learning curve, it is a complete programming language with lots of classes, APIs, etc. Don' try to learn everything at once, go step by step and master Java programming world.&lt;/p&gt;

&lt;h2&gt;Ways to learn Java Programming:&lt;/h2&gt;

&lt;h3&gt;Read books:&lt;/h3&gt;

&lt;p&gt;There are many good books from which you can learn Java Programming.&lt;br&gt;
Some of them are:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Head first Java&lt;/li&gt;
    &lt;li&gt;Effective Java&lt;/li&gt;
    &lt;li&gt;Thinking in Java&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Head first Java is my favorite among all. I really liked head first Java and enjoyed reading it. Head first Java explains Java Concepts in very unique and interesting way. You will be able to learn Class, Object, Thread, Collections and Generics and various other concepts.&lt;/p&gt;

&lt;h3&gt;Follow good Java blogs:&lt;/h3&gt;

&lt;p&gt;There are many good online blogs/website from which you can learn Java easily.&lt;/p&gt;

&lt;p&gt;Some of them are:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="https://docs.oracle.com/javase/tutorial/" rel="noopener noreferrer"&gt;Oracle docs&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a rel="nofollow noopener noreferrer" href="https://www.javacodegeeks.com/"&gt;Javacodegeeks&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a rel="nofollow noopener noreferrer" href="https://dzone.com/"&gt;Dzone&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;

&lt;p&gt;I have also created a &lt;a href="http://www.java2blog.com/2017/05/java-tutorial-for-beginners.html" rel="noopener noreferrer"&gt;complete core java tutorial for beginners and experienced programmers&lt;/a&gt; which will help you to learn Java Programming.&lt;/p&gt;

&lt;h2&gt;Tips to learn the internals of Java:&lt;/h2&gt;

&lt;h3&gt;Understand Java basics:&lt;/h3&gt;

&lt;p&gt;It is always essential to understand basics of any language when you get started. You need to understand basic concepts of Java such as &lt;a href="http://www.java2blog.com/2017/05/object-class-java.html" rel="noopener noreferrer"&gt;classes, objects&lt;/a&gt;, packages, &lt;a href="http://www.java2blog.com/2017/05/variables-java.html" rel="noopener noreferrer"&gt;variables&lt;/a&gt;, keywords, &lt;a href="http://www.java2blog.com/2017/05/data-types-in-java.html" rel="noopener noreferrer"&gt;data types &lt;/a&gt;etc.&lt;/p&gt;

&lt;h3&gt;Think in Object oriented way:&lt;/h3&gt;

&lt;p&gt;As you know Java is an Object oriented programming language, you need to understand object oriented concepts such as &lt;a href="http://www.java2blog.com/2017/04/abstraction-java-example.html" rel="noopener noreferrer"&gt;abstraction&lt;/a&gt;, &lt;a href="http://www.java2blog.com/2017/05/encapsulation-java-example.html" rel="noopener noreferrer"&gt;encapsulation&lt;/a&gt;, &lt;a href="http://www.java2blog.com/2017/05/polymorphism-java-example.html" rel="noopener noreferrer"&gt;polymorphism&lt;/a&gt;, and &lt;a href="https://java2blog.com/inheritance-java/" rel="noopener noreferrer"&gt;inheritance&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You need to think in terms of object and class. For example Employee has attributes such as name, age, and behavior such as completeAssignment etc.&lt;/p&gt;

&lt;h3&gt;Master Collections:&lt;/h3&gt;

&lt;p&gt;Collections framework is the most used framework in Java.Don't just understand the usage of collections such as HashMap, HashSet, TreeMap, Treeset but also understand the internal working of Collections.&lt;/p&gt;

&lt;p&gt;For example: If you know &lt;a href="http://www.java2blog.com/2014/02/how-hashmap-works-in-java.html" rel="noopener noreferrer"&gt;internal working of HashMap&lt;/a&gt; and then it is easy to debug program and see the content of HashMap. It will also help you understand how Java collections are designed.&lt;/p&gt;

&lt;p&gt;Let's take a very simple example. I have a Country class, we are going to use Country class object as key and its capital name(string) as value. Below example will help you to understand, how these key value pair will be stored in hashmap.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;1. Country.java &lt;/b&gt;&lt;/p&gt;

&lt;pre&gt;package org.arpit.java2blog;
public class Country {

 String name;
 long population;
 
 public Country(String name, long population) {
  super();
  this.name = name;
  this.population = population;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public long getPopulation() {
  return population;
 }
 public void setPopulation(long population) {
  this.population = population;
 }
 
 // If length of name in country object is even then return 31(any random number) and if odd then return 95(any random number).
 // This is not a good practice to generate hashcode as below method but I am doing so to give better and easy understanding of hashmap.
 &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;
 public int hashCode() {
  if(this.name.length()%2==0)
   return 31;
  else 
   return 95;
 }
 &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;
 public boolean equals(Object obj) {
  
  Country other = (Country) obj;
   if (name.equalsIgnoreCase((other.name)))
   return true;
  return false;
 }
  
}&lt;/pre&gt;

&lt;p&gt;If you want to understand more about hashcode and equals method of object, you may refer&lt;b&gt; &lt;a href="http://www.java2blog.com/2014/02/hashcode-and-equals-method-in-java.html" rel="noopener noreferrer"&gt;hashcode() and equals() method in java&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;2. HashMapStructure.java&lt;/b&gt;(main class)&lt;/p&gt;

&lt;pre&gt;import java.util.HashMap;
import java.util.Iterator;
  
public class HashMapStructure {
  
    /**
     * @author Arpit Mandliya
     */
    public static void main(String[] args) {
          
        Country india=new Country("India",1000);
        Country japan=new Country("Japan",10000);
          
        Country france=new Country("France",2000);
        Country russia=new Country("Russia",20000);
          
       HashMap&amp;lt;Country, String&amp;gt; countryCapitalMap=new HashMap&amp;lt;Country,String&amp;gt;();  
        countryCapitalMap.put(india,"Delhi");  
        countryCapitalMap.put(japan,"Tokyo");  
        countryCapitalMap.put(france,"Paris");  
        countryCapitalMap.put(russia,"Moscow");  
            
        Iterator countryCapitalIter=countryCapitalMap.keySet().iterator();//put debug point at this line  
        while(countryCapitalIter.hasNext())  
        {  
            Country countryObj=countryCapitalIter.next();  
            String capital=countryCapitalMap.get(countryObj);  
            System.out.println(countryObj.getName()+"----"+capital);  
         }  
        }  
  
  
}&lt;/pre&gt;

&lt;p&gt;Now put debug point at line 24 and right click on project-&amp;gt;debug as-&amp;gt; java application. Program will stop execution at line 24 then right click on countryCapitalMap then select watch.You will be able to see structure as below.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://3.bp.blogspot.com/-T4TsTlhwaXU/Uwjj9ypm69I/AAAAAAAACsY/J4-a6rxZLLE/s1600/HashMapStructure1.bmp" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F3.bp.blogspot.com%2F-T4TsTlhwaXU%2FUwjj9ypm69I%2FAAAAAAAACsY%2FJ4-a6rxZLLE%2Fs1600%2FHashMapStructure1.bmp" alt="How HashMap works in java"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now From above diagram, you can observe following points&lt;/p&gt;

&lt;p&gt;You have put 4 entries in HashMap but you see only two entries in Entry[] array. If you want to understand why there are only two entries in Entry[] array, you need to understand &lt;a href="http://www.java2blog.com/2014/02/how-hashmap-works-in-java.html" rel="noopener noreferrer"&gt;How HashMap works in &lt;/a&gt;java and Hashcode and equals method.&lt;/p&gt;

&lt;p&gt;This is a very simple HashMap example but you might much more complex example in real life, hence to debug the program and see values in HashMap, it is essential to learn the internal working of HashMap.&lt;/p&gt;

&lt;h3&gt;Choose any IDE:&lt;/h3&gt;

&lt;p&gt;You can choose IDE such as Eclipse, intellij or Netbeans. It will help you to do programming faster and will in turn increase your efficiency. You should also learn some important keyboard shorts for that IDE.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;When you copy any code and put any code in eclipse, you need to import all import statements for that program, you can simply use &lt;a href="http://www.java2blog.com/2016/02/how-to-import-all-classes-at-once-in.html" rel="noopener noreferrer"&gt;control+ shift+ O in eclipse&lt;/a&gt; and it will take care of imports. Hence it will help you to increase your efficiency while programming.&lt;/p&gt;

&lt;h3&gt;Write Basic Programs:&lt;/h3&gt;

&lt;p&gt;Practice &lt;a href="http://www.java2blog.com/2017/06/java-interview-programs-for-freshers.html" rel="noopener noreferrer"&gt;basic java programs&lt;/a&gt; on String, Numbers and Array etc. It will help you to write simple logics.&lt;/p&gt;

&lt;h3&gt;Practice at HackerRank:&lt;/h3&gt;

&lt;p&gt;Once you are familiar with collections and object-oriented concepts, you can practice Java programming at &lt;a href="https://www.hackerrank.com/domains/java/java-introduction" rel="noopener noreferrer"&gt;HackerRank&lt;/a&gt;. it will help to master syntax and building logic.&lt;/p&gt;

&lt;h3&gt;Learn Multithreading:&lt;/h3&gt;

&lt;p&gt;It is quite hard to master Multithreading. It requires good amount of practice to learn multithreading as thread outputs are unpredictable in most of the cases. You can learn basics of threads such as &lt;a href="http://www.java2blog.com/2015/06/java-thread-example.html" rel="noopener noreferrer"&gt;how to create a thread&lt;/a&gt;, life cycle of thread and different method of Thread class such join, sleep, yield and thread synchronization.&lt;/p&gt;

&lt;p&gt;Once you are comfortable with basics of thread, learn executor framework. Java 5 has introduced executor framework which takes care about thread creation and management, you can just concentrate on business logic.&lt;/p&gt;

&lt;h3&gt;Create small Projects:&lt;/h3&gt;

&lt;p&gt;You can create simple projects of your choice such as Library Management, Transport system. Create a simple design, Identify major entities, use cases and write a Java application to solve the program.&lt;/p&gt;

&lt;h3&gt;Browse some good Projects on github:&lt;/h3&gt;

&lt;p&gt;There are many good open source projects on &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. You can browse some good projects, it will help you to understand some good practices on design and coding.&lt;/p&gt;

&lt;h3&gt;Learn design pattern:&lt;/h3&gt;

&lt;p&gt;It is always a good idea to learn some design patterns. Learn a few design patterns and apply them in Java applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For &lt;/strong&gt;example: &lt;a href="http://www.java2blog.com/2013/02/observer-design-pattern-in-java.html" rel="noopener noreferrer"&gt;Observer design pattern &lt;/a&gt;depicts publisher-subscriber relationship.You can identify use case and easily implement it in Java program.&lt;/p&gt;

&lt;h3&gt;Practice, Practice, and Practice:&lt;/h3&gt;

&lt;p&gt;There are no shortcuts to learn Java. If you want to become a good Java developer, you need to practice more and more.&lt;/p&gt;

&lt;p&gt;That's all about How to learn Java Programming. If you have more suggestions, please do comment.&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
