public int max(int[] v)
{
if(v.length == 1)
{
return v[0]; // Returns the first and only element.
}
if(v[0] > v[1]) // Is the first element bigger than the second?
{ // If so, we ignore the second element, and replace it with the first.
v[1] = v[0];
}
int[] u = new int[v.length - 1]; // New array with the size of v minus one.
for(int i = 0; i < u.length; i++)
{ // Skip the first element in v as it's always smaller or equal to the second one.
u[i] = v[i + 1];
}
return max(u); // Calls this method on our new array which only consists of one element.
}
}