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.
About Question com.enthuware.ets.scjp.v6.2.84 :
Moderator: admin
-
- Posts: 50
- Joined: Sun Nov 10, 2013 4:39 am
- Contact:
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.84 :
No, I do not know why it is that way. The API designers would be the best people to answer that.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Wed May 14, 2014 7:47 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.84 :
I think it's not API designers implementation, but Java's generic method + varargs specification.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.
Who is online
Users browsing this forum: No registered users and 19 guests