Fill in the missing code:

This recursive method returns "even" if the length of a give String is even, and "odd" if the length of the String is odd.

public static String foo(String s)

{

if (s.length() ==0)

return "even";

else if (s.length() = = 1)

return "odd";

else

//your code goes here

}

Respuesta :

Answer:

The complete code is given below:

Explanation:

import java.util.Scanner;

public class Prime

{

  public static String foo(String s)

{

if (s.length() ==0)

  return "even";

else if (s.length() == 1)

  return "odd";

else

   return foo(s.substring(0, s.length() - 2));

}

  public static void main(String[] args)

  {

     String s="Hello";

     System.out.println(foo(s));

  }

}