2

Can somebody tell me how to interpret the following code? I know how to use blocks to initialize multi-dimensional arrays, but exactly what the null does in this example has me stumped. What will the contents of the whole array be? Thanks.

int arry[][] = { {1, 2}, null };`

`

2 Answers 2

2

Following is same, In Java, array is also another object, so assign null is perfectly OK

arry[0] = {1, 2};
arry[1] = null;
Sign up to request clarification or add additional context in comments.

Comments

1

Java does not have multi-dimensional arrays. It only has arrays of arrays.

arry is an array of 2 int[]s
    arry[0] is an array of 2 ints
        (arry[0])[0] is 1
        (arry[0])[1] is 2
    arry[1] is null

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.