title: Finding the second smallest integer in array
body: <p>We are required in our assignment to find the second smallest integer in one array recursively. However, for the sake of understanding the subject more, I want to do it iteratively first (with the help of this website) and recursively on my own. </p>
  
  <p>Unfortunately, doing it iteratively is quite confusing. I understand that the solution is simple but i can't wrap my head around it. </p>
  
  <p>Below is my code, so far: </p>
  
  <pre><code>public static void main(String[] args) 
  {
      int[] elements  = {0 , 2 , 10 , 3, -3 }; 
      int smallest = 0; 
      int secondSmallest = 0; 
  
      for (int i = 0; i &lt; elements.length; i++)
      {
          for (int j = 0; j &lt; elements.length; j++)
          {
              if (elements[i] &lt; smallest)
              {
                  smallest = elements[i];
  
                  if (elements[j] &lt; secondSmallest)
                  {
                      secondSmallest = elements[j];
                  }
              }
          }
  
      }
  
      System.out.println("The smallest element is: " + smallest + "\n"+  "The second smallest element is: " + secondSmallest);
  }
  </code></pre>
  
  <p>This works for a few numbers, but not all. The numbers change around because the inner if condition isn't as efficient as the outer if condition. </p>
  
  <p>Array rearrangements are forbidden. </p>