Selection and Bubble sorts
In addition to the other answers, there are a couple common bubble sort optimizations that you can employ.

First, your inner loop steps through the entire array each time. This is unnecessary because each pass through the array is guaranteed to sink the largest value to the bottom, so the tail of the array is always sorted. You can avoid processing the sorted bits of the array by using 

for (int j = 0; j &lt; lengthOfInputArray - (i + 1); j++) {
    ...
}


for the inner loop.

Second, you can shortcut processing by ending when the inner loop encounters no swaps.

public static void bubbleSort(int[] arr) {
    boolean swapped = false;

    for (int i = 0; i &lt; arr.length; i++) {
        swapped = false;
        for (int j = 0; j &lt; arr.length - (i + 1); j++) {
            if (arr[j] &gt; arr[j + 1]) {
                if (swap(arr, j, j + 1)) {
                    swapped = true;
                }
            }
        }
        if (!swapped) {
            break;
        }
    }
}


This only happens when the array is fully sorted. So if you start out with a sorted array, then you only have to run through the array once.

Third, the outer loop does not have to be processed once for each element in the array. Take a five element array for example. It is iterated in the following manner:

value of i      max j required
----------      --------------
    0                 3
    1                 2
    2                 1
    3                 0


So the outer loop only needs to be processed arr.length - 1 times. The final optimized bubble sort would look something like this:

public static void bubbleSort(int[] arr) {
    boolean swapped = false;

    for (int i = 0; i &lt; arr.length - 1; i++) {
        swapped = false;
        for (int j = 0; j &lt; arr.length - (i + 1); j++) {
            if (arr[j] &gt; arr[j + 1]) {
                if (swap(arr, j, j + 1)) {
                    swapped = true;
                }
            }
        }
        if (!swapped) {
            break;
        }
    }
}