About Question com.enthuware.ets.scjp.v6.2.84 :

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

Moderator: admin

Post Reply
devlam
Posts: 50
Joined: Sun Nov 10, 2013 4:39 am
Contact:

About Question com.enthuware.ets.scjp.v6.2.84 :

Post by devlam »

I did some checks on the behaviour of Arrays.asList() method and found that when you invoke it with a primitive-array it returns a List with primitive arrays (for example List<int[]>) whereas the invocation with an array of a certain object-class it returns a List of that object-class (for example List<String>).

Do you know why they implemented it this way? I was expecting also a List<int> as return value.

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

Re: About Question com.enthuware.ets.scjp.v6.2.84 :

Post by admin »

No, I do not know why it is that way. The API designers would be the best people to answer that.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

vaidaskz
Posts: 1
Joined: Wed May 14, 2014 7:47 am
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.84 :

Post by vaidaskz »

devlam wrote:I did some checks on the behaviour of Arrays.asList() method and found that when you invoke it with a primitive-array it returns a List with primitive arrays (for example List<int[]>) whereas the invocation with an array of a certain object-class it returns a List of that object-class (for example List<String>).

Do you know why they implemented it this way? I was expecting also a List<int> as return value.
I think it's not API designers implementation, but Java's generic method + varargs specification.

Post Reply

Who is online

Users browsing this forum: No registered users and 108 guests