Creating and Passing Arrays of Strings

Even though strings in Java are objects, they are treated separately for the convenience of using them with PIC X tables. Here is an example of creating a string array:

CALL "C$JAVA" USING CJAVA-CREATEARRAY, CJAVA-STRINGARRAY, 10 GIVING ARRAY-HANDLE.

Here are examples of setting a string array element. In this example, STRING-TABLE is declared PIC X(20) OCCURS 10.

MOVE "99999999999999999999" TO STRING-TABLE(10)

CALL "C$JAVA" USING CJAVA-SETARRAYELEMENT, ARRAY-HANDLE, 1, STRING-TABLE(10), GIVING STATUS-VAL.

This example demonstrates how to call a Java method that takes an array of strings as a parameter:

CALL "C$JAVA" USING CJAVA-CALL, OBJECT-HANDLE, "acuCobolGT/CAcuCobol", "CobolCallingJavaStringArray", "([Ljava/lang/String;)X", ARRAY-HANDLE, FIELD-STRINGRET GIVING STATUS-VAL.