[Solved] NullPointerException error in Insertion sort [closed]

You are not passing the array object to sort method. Try the following code: public class SortTest { public void sort(String[] array) { String insert; for (int next = 1; next < array.length; next++) { insert = array[next]; int moveItem = next; while (moveItem > 0 && array[moveItem – 1].compareTo(insert) > 0) { array[moveItem] = … Read more

[Solved] Khan Academy – Challenge: Implement insertion sort

The problem wasn’t that you were giving a wrong answer, it’s that you weren’t giving the coding solution they were expecting. On this particular problem, there’s a “hint” section in the upper right hand corner. If you click on the What’s this? link. This hint shows the code you’ll need to successfully complete this step, … Read more