Java code freezing mid execution
<p>Im running my code, and after it says the first print statement it pauses. It pauses at a point where it calls a function "insert" and simply doesnt respond anything. it prints "adding dog, cat, &amp; horse" but then just stops, doesnt do anything after that.</p>

<p>main function</p>

<pre><code>package assignment2;
public class Main {
    public static void main(String[] args) {
        OrderedStringList myList = new OrderedStringList(5);

        System.out.println("adding dog, cat, &amp; horse");
        myList.Insert("dog");
        myList.Insert("cat");
        myList.Insert("horse");

        myList.Display();

        System.out.println("Value pig find = "+ myList.Find("pig"));
        System.out.println("Value horse find = "+ myList.Find("horse"));

        System.out.println("Adding mouse &amp; rat");
        myList.Insert("mouse");
        myList.Insert("rat");

        myList.Display();

        System.out.println("myList size: "+ myList.Size());

        if (!myList.Insert("chinchilla"))
            System.out.println("Could not add chinchilla, full");

        System.out.println("Removing dog, adding chinchilla.");
        myList.Delete("dog");
        myList.Insert("chinchilla");

        myList.Display();
    }
}
</code></pre>

<p>here is my code of functions</p>

<pre><code>package assignment2;
public class OrderedStringList {
    int length;
    int numUsed;
    String[] storage;
    boolean ordered;

    public OrderedStringList(int size){
        length = size;
        storage = new String[length];
        numUsed = 0;
    }


    public boolean Insert(String value){
        boolean result = false;
                int index = 0;
                if (numUsed &lt; length) {
                    while (index &lt; numUsed) {
                        int compare = storage[index].compareTo(value);
                        if (compare &lt; 0)
                            index++;
                    }
                    moveItemsDown(index);
                    storage[index] = value;
                    numUsed++;
                    result = true;
                }
                return result;
    }
    private void moveItemsDown(int start){
        int index;
        for (index = numUsed-1; index &gt;=start; index--){
            storage[index+1] = storage[index];
        }
    }

    private void moveItemsUp(int start){
        int index;
        for (index = start; index &lt; numUsed-1; index++){
            storage[index] = storage[index+1];
        }
    }

    public boolean Find(String value){
        return (FindIndex(value) &gt;= 0);
    }

    private int FindIndex(String value) {
        int result = -1;
        int index = 0;
        boolean found = false;
        while ((index &lt; numUsed) &amp;&amp; (!found)) {
            found = (value.equals(storage[index]));
            if (!found)
                index++;
        }
        if (found)
            result = index;
        return result;
    }

    public boolean Delete(String value){
        boolean result = false;
        int location;
        location = FindIndex(value);
        if (location &gt;= 0) {
            moveItemsUp(location);
            numUsed--;
            result = true;
        }
        return result;
    }

    public void Display() {
        int index;
        System.out.println("list Contents: ");
        for (index = 0; index &lt; numUsed; index++) {
            System.out.println(index+" "+storage[index]);
        }
        System.out.println("-------------");
        System.out.println();
    }

    public void DisplayNoLF() {
        int index;
        System.out.println("list Contents: ");
        for (index = 0; index &lt; numUsed; index++) {
            System.out.print(storage[index]+" ");
        }
        System.out.println("-------------");
        System.out.println();
    }

    public int Size(){
        return numUsed;
    }
}
</code></pre>
