title: Selection Sorting in Java with Strings?
body: <p>I'm wondering if anyone could show me where my logic in this selection sort (yes it's for educational use, I realize that there's an Arrays.sort() method) is flawed.</p>
  
  <pre><code> public static void selectionSortByName() throws IOException {
      String temp;
      for (int i = 0; i &lt;= nameArraySize; i++){
  
          String smallest = name[i];
  
  
          for (int j = 0; j &lt;= nameArraySize; j++){
              if (name[j].compareTo(name[i]) &lt; 0){
                  temp = smallest;
                  name[j] = temp;
                  name[i] = smallest;
              }
          }
  
      }
    }
  </code></pre>
  
  <p>I'm getting a NullPointerException on my line with the compareTo method, so I would expect that I just have a logic error in one of my conditionals.</p>
  
  <p>Any help would be great, thanks!</p>