[HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

[HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]

Post by OCAJO1 »

Just curious,

Is there any advantage(s) in initializing using

int[] ia = new int[]{ 1, 2, 3, 4, 5 };

over

int[] ia = {1, 2, 3, 4, 5 };

Thanks

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

Re: [HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]

Post by admin »

Some may find the former more clear while others may find the later less tedious. But no other adv/disadv.
If you like our products and services, please help us by posting your review here.

OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

Re: [HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]

Post by OCAJO1 »

One of the things that I've noticed about Java. It gives the exam producers lots of options to play with:)

Username987654
Posts: 95
Joined: Sat Dec 26, 2015 6:37 pm
Contact:

Re: [HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]

Post by Username987654 »

boolean[] ba = new boolean[3]; //an array of booleans of size 2
should be
boolean[] ba = new boolean[3]; //an array of booleans of size 3
?

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

Re: [HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]

Post by admin »

Correct. Added to errata.
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 64 guests