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.
public static void selectionSortByName() throws IOException {
String temp;
for (int i = 0; i <= nameArraySize; i++){
String smallest = name[i];
for (int j = 0; j <= nameArraySize; j++){
if (name[j].compareTo(name[i]) < 0){
temp = smallest;
name[j] = temp;
name[i] = smallest;
}
}
}
}
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.
Any help would be great, thanks!