class_docstr: Wrapper class for a Java companion object
class_docstr_tok: ["Wrapper","class","for","a","Java","companion","object"]
docstr: Create a Java array of given java_class type. Useful for
  calling a method with a Scala Array from Python with Py4J.
  If the param pylist is a 2D array, then a 2D java array will be returned.
  The returned 2D java array is a square, non-jagged 2D array that is big
  enough for all elements. The empty slots in the inner Java arrays will
  be filled with null to make the non-jagged 2D array.
  
  Parameters
  ----------
  pylist : list
      Python list to convert to a Java Array.
  java_class : :py:class:`py4j.java_gateway.JavaClass`
      Java class to specify the type of Array. Should be in the
      form of sc._gateway.jvm.* (sc is a valid Spark Context).
  
      Example primitive Java classes:
  
      - basestring -> sc._gateway.jvm.java.lang.String
      - int -> sc._gateway.jvm.java.lang.Integer
      - float -> sc._gateway.jvm.java.lang.Double
      - bool -> sc._gateway.jvm.java.lang.Boolean
  
  Returns
  -------
  :py:class:`py4j.java_collections.JavaArray`
    Java Array of converted pylist.
docstr_tok: ["Create","a","Java","array","of","given","java_class","type",".","Useful","for","calling","a","method","with","a","Scala","Array","from","Python","with","Py4J",".","If","the","param","pylist","is","a","2D","array",",","then","a","2D","java","array","will","be","returned",".","The","returned","2D","java","array","is","a","square",",","non-jagged","2D","array","that","is","big","enough","for","all","elements",".","The","empty","slots","in","the","inner","Java","arrays","will","be","filled","with","null","to","make","the","non-jagged","2D","array",".","Parameters","--","--","--","--","--","pylist",":","list","Python","list","to","convert","to","a","Java","Array",".","java_class",":",":","py",":","class",":","`","py4j.java_gateway.JavaClass","`","Java","class","to","specify","the","type","of","Array",".","Should","be","in","the","form","of","sc._gateway.jvm",".","*","(","sc","is","a","valid","Spark","Context",")",".","Example","primitive","Java","classes",":","-","basestring","-",">","sc._gateway.jvm.java.lang.String","-","int","-",">","sc._gateway.jvm.java.lang.Integer","-","float","-",">","sc._gateway.jvm.java.lang.Double","-","bool","-",">","sc._gateway.jvm.java.lang.Boolean","Returns","--","--","--","-",":","py",":","class",":","`","py4j.java_collections.JavaArray","`","Java","Array","of","converted","pylist","."]
code: def _new_java_array(
      pylist: List[Any], java_class: "JavaClass"
  ) -> "JavaObject":
      """
      Create a Java array of given java_class type. Useful for
      calling a method with a Scala Array from Python with Py4J.
      If the param pylist is a 2D array, then a 2D java array will be returned.
      The returned 2D java array is a square, non-jagged 2D array that is big
      enough for all elements. The empty slots in the inner Java arrays will
      be filled with null to make the non-jagged 2D array.
  
      Parameters
      ----------
      pylist : list
          Python list to convert to a Java Array.
      java_class : :py:class:`py4j.java_gateway.JavaClass`
          Java class to specify the type of Array. Should be in the
          form of sc._gateway.jvm.* (sc is a valid Spark Context).
  
          Example primitive Java classes:
  
          - basestring -> sc._gateway.jvm.java.lang.String
          - int -> sc._gateway.jvm.java.lang.Integer
          - float -> sc._gateway.jvm.java.lang.Double
          - bool -> sc._gateway.jvm.java.lang.Boolean
  
      Returns
      -------
      :py:class:`py4j.java_collections.JavaArray`
        Java Array of converted pylist.
      """
      sc = SparkContext._active_spark_context
      assert sc is not None
      assert sc._gateway is not None
  
      java_array = None
      if len(pylist) > 0 and isinstance(pylist[0], list):
          # If pylist is a 2D array, then a 2D java array will be created.
          # The 2D array is a square, non-jagged 2D array that is big enough for all elements.
          inner_array_length = 0
          for i in range(len(pylist)):
              inner_array_length = max(
                  inner_array_length, len(pylist[i])
              )
          java_array = sc._gateway.new_array(
              java_class, len(pylist), inner_array_length
          )
          for i in range(len(pylist)):
              for j in range(len(pylist[i])):
                  java_array[i][j] = pylist[i][j]
      else:
          java_array = sc._gateway.new_array(java_class, len(pylist))
          for i in range(len(pylist)):
              java_array[i] = pylist[i]
      return java_array
  
imports: from abc import ABCMeta, abstractmethod
  from typing import Any, Generic, Optional, List, Type, TypeVar, TYPE_CHECKING
  from pyspark import since
  from pyspark import SparkContext
  from pyspark.sql import DataFrame
  from pyspark.ml import Estimator, Predictor, PredictionModel, Transformer, Model
  from pyspark.ml.base import _PredictorParams
  from pyspark.ml.param import Param, Params
  from pyspark.ml.util import _jvm
  from pyspark.ml.common import inherit_doc, _java2py, _py2java
label_desc: Use image node_id 6 for calling the JavaWrapper obj's underlying member method code with example usage: obj._new_java_array(pylist, java_class) and returns: java_array