Answer:
boolean isEven = false;
if (x.length % 2 == 0)
isEven = true;
Comparable currentMax;
int currentMaxIndex;
for (int i = x.length - 1; i >= 1; i--)
{
currentMax = x[i];
currentMaxIndex = i;
for (int j = i - 1; j >= 0; j--)
{
if (((Comparable)currentMax).compareTo(x[j]) < 0)
{
currentMax = x[j];
currentMaxIndex = j;
}
}
x[currentMaxIndex] = x[i];
x[i] = currentMax;
}
Comparable a = null;
Comparable b = null;
if (isEven == true)
{
a = x[x.length/2];
b = x[(x.length/2) - 1];
if ((a).compareTo(b) > 0)
m = a;
else
m = b;
}
else
m = x[x.length/2];