int[] arrc = new int[] {1, 2, 3};
System.out.println(new ArrayList(Arrays.asList(arrc)));
prints address, but i desire to use toString as in ArrayList.
Is it possible ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try:
Note that the
asList(...)does not take an array of primitiveint‘s but takesObjects instead, that’s why you see an address-like String appear.So, doing:
results in the same as doing:
Both result in a List that has one element in it: an array of primitive
ints.(only that
Arrays.asList(...)returns a List that cannot be modified…)