title: finding the shortest word in an array of strings java
body: <p>im trying to write a code to take in a group of words, and return the smallest word in character length. pretty simple, for some reason its returning 'bye' when there is a shorter word in there such as 'no'. </p>
  
  <pre><code>public class function2 {
  
      public static void main(String [] args) {
          String [] SA = {"hello", "goodbye", "jack", "bye", "yes", "no", "yoo"};
          smallest(SA);
          System.out.println("The shortest word is " + smallest(SA));
      }
  
      public static String smallest(String SA[]) {
          String first = SA[0];
          for (int i = 1 ; i &lt; SA.length ; i++) {
              if ((SA[i].compareTo(first)) &lt; 0) {
                  first = SA[i];
              } // if
          } // for
          return first;
      }// smallest
  }// lab1b
  </code></pre>