About Question enthuware.ocpjp.i.v11.2.3228 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
noeloo
Posts: 61
Joined: Sat Feb 15, 2020 8:56 am
Contact:

About Question enthuware.ocpjp.i.v11.2.3228 :

Post by noeloo »

Shouldn't this sentence be rewritten?
So for example, a[] [] [] [] = new int[4] [3] [3] [5]; is same as a[] [] [] [] = new int [4] [] [] [];
In fact, the effect of such created variables is different - the first one is initialized with nulls, and the second - with arrays.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.i.v11.2.3228 :

Post by admin »

Actually, the type of the variables created in both are exactly the same and the objects referred to by the variables in both the cases are also exactly same i.e. in both the cases, a refers to an int array of arrays of arrays or arrays (which is what the explanation is trying to get at). The difference is in the way the two arrays are initialized. In case of new int [4] [] [] [], only the elements of the first dimention are iniliazed (to null), while in case of new int[4] [3] [3] [5]; all elements of all dimensions are initialized to non null arrays (or 0 in the last dimension.)

Explanation has now been enhanced to make this point clear.

thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests