title: Java - To find the Second Highest Digit
body: <p>I need to: </p>
  
  <p>Write a function that accepts a string and returns the second highest numerical digit in the input as an integer.</p>
  
  <p>The following rules should apply:</p>
  
  <ul>
  <li><p>Inputs with no numerical digits should return -1 </p></li>
  <li><p>Inputs with only one    numerical digit should return -1 </p></li>
  <li><p>Non-numeric characters should be    ignored </p></li>
  <li><p>Each numerical input should be treat individually, meaning in the
  event of a joint highest digit then the second highest digit will
  also be the highest digit</p></li>
  </ul>
  
  <p>For example:</p>
  
  <ul>
  <li>"abc:1231234" returns 3</li>
  <li>"123123" returns 3</li>
  </ul>
  
  <p>This is my code currently: </p>
  
  <pre><code>public class Solution {
      public static int secondHighestDigit(String input) {
  
      try{
  
          int k = Integer.parseInt(input); 
  
          char[] array = input.toCharArray(); 
  
          int big = Integer.MIN_VALUE;
          int secondBig = Integer.MIN_VALUE;
  
  
          for(int i = 0; i &lt; array.length; i++){
  
              System.out.println(array[i]);
  
              for(int n = 0; n &lt; array[i]; n++){
                  if(array[i] &gt; big)
                  {
                      secondBig = big;
                      big = array[i];
                  }else if(array[i] &gt; secondBig &amp;&amp; array[i] != big){
                      secondBig = array[i];
                  }
              }
  
          }
  
          System.out.println(secondBig);
  
          }catch(Exception e) {
          System.out.println("-1");
      }
      return -1;
      }
  
  }
  </code></pre>
  
  <p>Tests:</p>
  
  <pre><code>import org.junit.*;
  import static org.junit.Assert.*;
  
  public class Tests
  {
  
      @Test
      public void test1()
      {
          Solution solution = new Solution();
  
          assertEquals(3, solution.secondHighestDigit("abc:1231234"));
      }
  
      @Test
      public void test2()
      {
          Solution solution = new Solution();
  
          assertEquals(3, solution.secondHighestDigit("123123"));
       }
  }
  </code></pre>
  
  <p>The program should print 3 for abc:1231234 and 123123 but instead it is returning -1 for both.</p>
  
  <p>I am lost are where to go from here. I would be grateful if someone could help. Thanks.</p>