Two string comparison I wrote a function that finds the difference between two strings. This only works given that the difference is continuous.

Beyond doubt this already exists, I am recreating this for educational purposes. I would like feedback about my performance and efficiency.

Examples of this method:

String difference = Difference("Hello", "Hello world!");
//difference would be " world!"

String difference = Difference("Removing text", "Removi");
//difference would be "ng text"

String difference = Difference("same size", "SAME size");
//difference would be "SAME"




public static String Difference(String string1, String string2)
{
    int size = string2.length() - string1.length();
    if(size &lt; 0)
    {
        size *= -1;
        String swap = string1;
        string1 = string2;
        string2 = swap;
    }
    String difference = "";
    int start = DifferenceStartIndex(string1, string2);
    if(size &gt; 0)
        for(int i = start; i &lt; start + size; i++)
            difference += string2.charAt(i);
    else
    {
        if(start != -1)
        {
            int end = DifferenceEndIndex(string1, string2, start);
            for(int i = start; i &lt; end; i++)
                difference += string2.charAt(i);
        }
        else
            return "";
    }
    return difference;
}

public static int DifferenceStartIndex(String string1, String string2)
{
    int maxSize = (string1.length() &gt; string2.length()) ? string1.length() : string2.length();
    for(int i = 0; i &lt; maxSize; i++)
        if(((i &lt; string1.length()) ? string1.charAt(i) : '\0') != ((i &lt; string2.length()) ? string2.charAt(i) : '\0'))
            return i;
    return -1;
}

public static int DifferenceEndIndex(String string1, String string2, int start)
{
    int maxSize = (string1.length() &gt; string2.length()) ? string1.length() : string2.length();
    int end = maxSize;
    for(int i = start; i &lt; maxSize; ++i)
        if(string1.charAt(i) != string2.charAt(i))
            end = i + 1;
    return end;
}
Conventions
In java, methods begin with a lowercase letter.
Design
Methods should be private unless they are required by clients. In this case, only the difference() method should be public.
Implementation
There are a few things to look at here. First, your code is made much more complex by swapping around the two inputs based on size. It would be neater if you did the size comparison once, then called a helper method with parameters shorterString and longerString.
Your two size methods are clunky because they don't return early when they find a (mis)match, and because they run off of the longer string rather than the shorter string.
There may be a slight performance gain to be made if the two strings are frequently equal. In that case only, it may be faster to check if the two strings are equals() and return -1 from differenceStartIndex() right away. In your particular case, I highly doubt this check would be anything more than clutter.
Applying these changes might make the code look something like:
public final class Difference {

    public static String difference(final String string1, final String string2) {
        if (string1.length() &lt;= string2.length()) {
            return differenceHelper(string1, string2);
        }
        return differenceHelper(string2, string1);
    }

    private static String differenceHelper(final String shorterString, final String longerString) {
        final int start = differenceStartIndex(shorterString, longerString);
        if (start &lt; 0) {
            return &quot;&quot;;
        }
        final int end = differenceEndIndex(shorterString, longerString, start);
        return longerString.substring(start, end);
    }

    private static int differenceStartIndex(final String shorterString, final String longerString) {
        for (int i = 0; i &lt; shorterString.length(); i++) {
            if (shorterString.charAt(i) != longerString.charAt(i)) {
                return i;
            }
        }

        if (shorterString.length() == longerString.length()) {
            return -1;
        }

        return shorterString.length();
    }

    private static int differenceEndIndex(final String shorterString, final String longerString, final int startIndex) {
        for (int i = startIndex; i &lt; shorterString.length(); i++) {
            if (shorterString.charAt(i) == longerString.charAt(i)) {
                return i + 1;
            }
        }
        return longerString.length();
    }

    public static void main(final String[] argv) {
        System.out.println(Difference.difference(&quot;Hello&quot;, &quot;Hello world!&quot;));
        System.out.println(Difference.difference(&quot;Removing text&quot;, &quot;Removi&quot;));
        System.out.println(Difference.difference(&quot;same size&quot;, &quot;SAME size&quot;));

    }
}