Write a method min that has three string parameters and returns the smallest

LANGUAGE: Java

CHALLENGE:

Write a method min that has three string parameters and returns the smallest.

SOLUTION:

public String min (String x, String y, String z)
{
    String min = " ";
    if ((x.compareTo(y)<0) && (x.compareTo(z)<0))
    {
        min=x;
    }
    else if ((y.compareTo(z)<0) && (y.compareTo(x)<0))
    {
        min=y;
    }
    else if ((z.compareTo(x)<0) && (z.compareTo(y)<0))
    {
        min=z;
    }

    return min;
}