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
[HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]
Moderator: admin
-
- Posts: 221
- Joined: Mon Nov 26, 2018 2:43 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]
Some may find the former more clear while others may find the later less tedious. But no other adv/disadv.
-
- Posts: 221
- Joined: Mon Nov 26, 2018 2:43 pm
- Contact:
Re: [HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]
One of the things that I've noticed about Java. It gives the exam producers lots of options to play with:)
-
- Posts: 95
- Joined: Sat Dec 26, 2015 6:37 pm
- Contact:
Re: [HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]
should beboolean[] ba = new boolean[3]; //an array of booleans of size 2
?boolean[] ba = new boolean[3]; //an array of booleans of size 3
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 95, Sec. 4.1.2 - creating-and-initializing-array-objects]
Correct. Added to errata.
thank you for your feedback!
thank you for your feedback!
Who is online
Users browsing this forum: No registered users and 5 guests