title: How to get the max/min value of a String[] array?
body: <p>I got the idea to check for the max/min value of an array from <a href="http://www.java-examples.com/find-largest-and-smallest-number-array-example" rel="nofollow" title="Java-Examples">here</a>. It works wonders, but I'm wondering if there's a way to tear the code apart and make it more compact. Maybe there's a command of some sort? I don't know, and that's why I'm asking you.</p>
  
  <pre><code>public static void main(String[] args) {
      String[] input = JOptionPane.showInputDialog("What are you grades this month?\nThey must be seperated by spaces.").split(" ");
  
      int smallest = Integer.parseInt(input[0]);
      int largest = Integer.parseInt(input[0]);
  
      for (int i = 1; i &lt; input.length; i++) {
          if (Integer.parseInt(input[i]) &gt; largest) { 
             largest = Integer.parseInt(input[i]); 
          }
          else if (Integer.parseInt(input[i]) &lt; smallest) { 
            smallest = Integer.parseInt(input[i]); 
          }
      }
  }
  </code></pre>