title: What is the use of Pair Class and why have the implemented here?
body: <p>What is the difference between a <code>Pair Class and a HashMap</code>. I see both of them having <code>key and value</code>.  </p>
  
  <p><strong>Code Earlier:</strong> </p>
  
  <pre><code> List&lt;Patient&gt; patientDetails = new ArrayList&lt;Patient&gt;();
   Patient patientInfo = new Patient();
   patientInfo.setReligion(Constants.ReligionArray[custom.getReligion()]);
   patientDetails.add(patientInfo);
  </code></pre>
  
  <p>The code has been changed to this today. </p>
  
  <p><strong>Changed Code</strong></p>
  
  <pre><code>List&lt;Pair&lt;String, String&gt;&gt; patientInfo = new ArrayList&lt;Pair&lt;String, String&gt;&gt;();
  patientInfo.add(new Pair&lt;String, String&gt;("Religion", Constants.ReligionArray[custom.getReligion()]));
  </code></pre>
  
  <ol>
  <li>Why have they implemented a <code>Pair Class here?</code> What could be the reason.</li>
  <li>What is the difference between a <code>Pair Class and a HashMap</code>.</li>
  </ol>
  
  <p>Note: Both the code works perfectly.</p>