Explanation
This method generates a String object having the character string specified for the alphanumeric data item as an initial value.
Syntax
INVOKE class-name "NEW-STRING-X" USING initialValue RETURNING createdObject
Parameter and return value
Specifies the internal class name of the java-lang-String class declared in the REPOSITORY paragraph.
Specifies an alphanumeric data item as the initial value of the String object.
Returns the generated object.
Supplement
When a data name is specified for initialValue, a String object as long as data item length is generated. However, inserting X"00" in the statement can generate a String object shorter than data item length.
... REPOSITORY. CLASS J-String AS "java-lang-String" ... WORKING-STORAGE SECTION. 01 initialValue PIC X(50). 01 aString OBJECT REFERENCE J-String. ... PROCEDURE DIVISION. ... MOVE "ABC" TO initialValue. INVOKE J-String "NEW-STRING-X" USING initialValue RETURNING aString. [1] ... MOVE "ABC" & X"00" TO initialValue. INVOKE J-String "NEW-STRING-X" USING initialValue RETURNING aString. [2]
A String object consisting of 50 characters with the last 47-character area padded with blanks is generated.
A String object consisting of three characters is generated.