Longest Common Prefix in an array of Strings
Pure functions should generally be declared static.

You shouldn't need to take substrings in a loop — that's inefficient.  Think of scanning a two-dimensional ragged array of characters.  Check that all of the first characters match, then that all of the second characters match, and so on until you find a mismatch, or one of the strings is too short.

public static String longestCommonPrefix(String[] strings) {
    if (strings.length == 0) {
        return "";   // Or maybe return null?
    }

    for (int prefixLen = 0; prefixLen &lt; strings[0].length(); prefixLen++) {
        char c = strings[0].charAt(prefixLen);
        for (int i = 1; i &lt; strings.length; i++) {
            if ( prefixLen &gt;= strings[i].length() ||
                 strings[i].charAt(prefixLen) != c ) {
                // Mismatch found
                return strings[i].substring(0, prefixLen);
            }
        }
    }
    return strings[0];
}


Space complexity: O(1).

Worst-case time complexity: O(n m) to scan every character in every string.