Nadeen
0
Q:

If there are an odd number of elements in the array, return the element in the middle of the array.

public String middleElement(String[] array)
{
    if (array.length >=1){
        if (array.length %2 != 0){
            return array[array.length/2];
        }
        else if(array.length %2 == 0){
            return array[array.length/2];
        }
        return "";
    }
    else return "";
}
0

New to Communities?

Join the community