source: java2python/core/src/test/java/testcode/ArrayAccess.java

Last change on this file was 1220, checked in by wouter, 6 weeks ago

#382 added test showing issue with array initialiaation.

File size: 777 bytes
Line 
1package testcode;
2
3import org.eclipse.jdt.annotation.NonNull;
4
5public class ArrayAccess {
6
7 static public void main(String[] args) {
8 final @NonNull String[] s = { "1", "2" };
9
10 final int[] vals = { 1, 2 };
11 int sum = vals[0] + vals[1];
12 System.out.println(sum);
13
14 int[][] ar = new int[4][2];
15 for (int x = 0; x < 4; x += 1) {
16 for (int y = 0; y < 2; y += 1)
17 ar[x][y] = x + y;
18 }
19 System.out.println(ar[3][1]);
20
21 int[][][] ar2 = new int[3][2][];
22 // should give [[n,n],[n,n],[n,n]] (n=null)
23 // = [n]*2*3
24 System.out.println(ar2[2][1] == null);
25
26 Integer[][] m = new Integer[3][3];
27 m[0][0] = 1;
28 m[1][0] = 0;
29 // #382 check array init was done properly.
30 System.out.println(m[0][0].toString()); //1
31 System.out.println(m[1][0].toString()); // 0
32
33 }
34}
Note: See TracBrowser for help on using the repository browser.