input: from typing import List
  
  
  def port_java_to_python(java_code: str) -> str:
      """ Given a Java code snippet (in a string format) defining a public class with a public method, 
      port the method from Java to Python 3, preserving the method signature and functionality.
      Example:
      For port_java_to_python('public class Foo { public int foo( int a, int b ) { return a + b; } }'),
      the output should be 'def foo(a, b):\n return a + b'
      """
output:     
      java_code = java_code.strip()
      method_start = java_code.find("public")
      method_end = java_code.find("}", method_start)
      method_code = java_code[method_start:method_end]
      
      method_code = method_code.replace("public", "").replace("class", "").replace("int", "").replace("String", "").replace("boolean", "").replace("float", "").replace("double", "").replace("char", "").replace("void", "")
      method_code = method_code.replace("{", "").replace("}", "").replace(";", "")
      method_code = method_code.strip()
      
      method_name_start = method_code.find(" ")
      method_name_end = method_code.find("(", method_name_start)
      method_name = method_code[method_name_start:method_name_end].strip()
      
      params_start = method_code.find("(", method_name_end) + 1
      params_end = method_code.find(")", params_start)
      params = method_code[params_start:params_end].strip()
      
      body_start = method_code.find("{", params_end) + 1
      body_end = method_code.find("}", body_start)
      body = method_code[body_start:body_end].strip()
      
      if params:
          params = params.split(", ")
          params = ", ".join([p.split(" ")[1] for p in params])
      
      python_code = f"def {method_name}({params}):\n return {body}"
      return python_code
  