Selection and Insertion sorts from scratch in Java I am trying to find a good, basic way to make selection and insertion sorts so that I can manipulate them for other sorting techniques. How do these look? Is there a simpler way to write them?

package javaapplication59;

public class JavaApplication59 {

public static void main(String[] args) {
    selectionSort ss = new selectionSort();
    insertionSort is = new insertionSort();
    int[] arr = {2, 3, 4, 65, 6, 7, 3, 45, 56, 23, 34, 5, 4, 34, 6, 2, 57, 4, 45, 345};
    arr = is.sort(arr);
    System.out.print("{");
    for (int el : arr) {
        System.out.print(el + ",");
    }
    System.out.println("\b}");
}

}

class insertionSort {

public int[] sort(int[] a) {
    int insrt, j;
    boolean keepGoing;
    for (int i = 1; i &lt; a.length; i++) {
        insrt = a[i];
        j = i - 1;
        keepGoing = true;
        while ((j &gt;= 0) &amp;&amp; keepGoing) {
            if(insrt&lt;a[j]){
                a[j+1] = a[j];
                j--;
                if(j==-1)
                    a[0] = insrt;
            }
            else{
                keepGoing = false;
                a[j+1] = insrt;
            }

        }

    }
    return a;
}

}

class selectionSort {

public int[] sort(int[] arr) {
    int min, minIndex;
    for (int i = 0; i &lt; arr.length; i++) {
        min = arr[i];
        minIndex = i;
        for (int j = i + 1; j &lt; arr.length; j++) {
            if (arr[j] &lt; min) {
                min = arr[j];
                minIndex = j;
            }
        }
        arr[minIndex] = arr[i];
        arr[i] = min;
    }
    return arr;
}

}
Please try to follow the code formatting conventions of the language that you're using. This makes your code much more readable for other programmers.
If you use a Java IDE like Eclipse, NetBeans or IntelliJ it can format the code for you. In Eclipse this is triggered by pressing Ctrl+Shift+F.

Your use of CamelCase for identifiers is correct but only methods should start with lower case, class names start with a capital letter.

Don't abbreviate english words unnecessarily. Writing insrt instead of insert gains you nothing and makes the code harder to read.

You're defining classes that have the same behavior, so it would be good to define a common interface so you can use them interchangeable.

interface Sort {
    void sort(int[] a);
}

class InsertionSort implements Sort {
    // ...
}

class SelectionSort implements Sort {
    // ...
}


For your print statement you can use StringJoiner. It's specially built for your use case and allows you to specify a delimiter, prefix and suffix.

public static void main(String[] args) {
    Sort ss = new SelectionSort();
    Sort is = new InsertionSort();
    int[] arr = { 2, 3, 4, 65, 6, 7, 3, 45, 56, 23, 34, 5, 4, 34, 6, 2, 57, 4, 45, 345 };
    is.sort(arr);
    StringJoiner sj = new StringJoiner(",", "{", "}");
    for (int el : arr) {
        sj.add(String.valueOf(el));
    }
    System.out.println(sj);
}


Since you sort the array in-place (you don't create a new array during sort) for both algorithms you don't have to return the array. The reference that you hold on it outside is enough.

Your Insertion Sort can be simplified by getting rid of the keepGoing boolean.
You move the conditional from the if statement into the head of the while loop.
You want the while loop to continue while a[j] &gt; insrt, no need for an extra variable. Then you move the actual insertion out of the else clause and put it after the while loop.
Your're going to be at the right insertion spot once the while loop has finished.

class InsertionSort implements Sort {

    public void sort(int[] a) {
        int insert, j;
        for (int i = 1; i &lt; a.length; i++) {
            insert = a[i];
            j = i - 1;
            while ((j &gt;= 0) &amp;&amp; a[j] &gt; insert) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = insert;
        }
    }
}


You SelectionSort looks fine to me.