input: Write a function to convert a given Java code snippet to Python 3 code. The function should take a string representation of the Java code and return the equivalent Python code as a string.
  assert port_java_to_python("public class Foo { public int foo( int a, int b ) { return a + b; } }")=='''def foo(a, b):\n return a + b'''
  assert port_java_to_python("public class Bar { public void bar() { System.out.println(\"Hello, World!\"); } }")=='''def bar():\n print("Hello, World!")'''
  assert port_java_to_python("public class FooBar { public String fooBar(String s) { return s.toUpperCase(); } }")=='''def fooBar(s):\n return s.upper()'''
  assert port_java_to_python("")==''''''
  assert port_java_to_python("public class Example { public int example( int a ) { return a * 2; } }")=='''def example(a):\n return a * 2'''
output: def port_java_to_python(java_code):
      if not java_code:
          return ""
      java_code = java_code.strip()
      if not java_code.startswith("public class"):
          return ""
      method_start = java_code.find("{") + 1
      method_end = java_code.rfind("}")
      method_code = java_code[method_start:method_end].strip()
      method_code = method_code.replace("public ", "").replace("private ", "").replace("protected ", "")
      method_code = method_code.replace("void ", "def ").replace("String ", "str ").replace("int ", "int ")
      method_code = method_code.replace("System.out.println", "print")
      method_code = method_code.replace("return ", "return ")
      method_code = method_code.replace(";", "")
      method_code = method_code.replace("toUpperCase()", "upper()")
      method_code = method_code.replace("{", ":\n").replace("}", "")
      method_code = method_code.replace("(", "(").replace(")", ")")
      method_code = method_code.replace("  ", " ")
      method_code = method_code.replace("def ", "def ")
      method_code = method_code.replace("return ", "return ")
      method_code = method_code.replace("print ", "print(") + ")" if "print" in method_code else method_code
      return method_code.strip()