public class arrays { public static void main (String[] args) { String[][] strarr = new String[3][2]; String[] subarr = new String[2]; subarr[0] = "OK"; subarr[1] = "OK"; strarr[0] = subarr; System.out.println (strarr[0][0]); System.out.println (strarr[0][1]); } } |
program-id. arrays. configuration section. repository. class StringArr1 as "java.lang.String[]" class StringArr2 as "java.lang.String[][]" class JSystem as "java.lang.System" . working-storage section. 77 subarr object reference StringArr1. 77 strarr object reference StringArr2. procedure division. main. set strarr to StringArr2:>new(3, 2). set subarr to StringArr1:>new(2). set subarr(0) to "OK". set subarr(1) to "OK". set strarr(0) to subarr. JSystem:>out:>println(strarr(0, 0)). JSystem:>out:>println(strarr(0, 1)). goback. |
program-id. arrays. configuration section. repository. class StringArr1 as "java.lang.String[]" class StringArr2 as "java.lang.String[][]" class JSystem as "java.lang.System" . working-storage section. 77 subarr object reference StringArr1. 77 strarr object reference StringArr2. 77 i pic 9(3). procedure division. main. set strarr to StringArr2:>new(3, 2). set subarr to StringArr1:>new(2). set subarr(0) to "OK". set subarr(1) to "OK". perform varying i from 0 by 1 until i = subarr:>length() set strarr(0, i) to subarr(i) end-perform. JSystem:>out:>println(strarr(0, 0)). JSystem:>out:>println(strarr(0, 1)). goback. |