• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conversion toArray and asList problem

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Queries

1.The output of line 23-24 is
[[I@3e25a5]

shouldn't it be 3,5,76,8,5,345436 ?

2.The output of line 27-29 is

[[I@3e25a5]

why i am getting this ambiguous output ?
how to get the content of object array ob ?

3.In the lines 43-47
the array dimension is 0 still the array named incompletearray prints the data contained in the list ab
can anyone tell me how this possible ?

4. The code of lines 50-53 is commented.

when i put the commented code,i get this error java uses unchecked or unsafe operations.
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know that the abws is a list and actually it is an object isn't it?
like arrays... lists are also objects in java
so when you just print the abws variable, it gives the hashcode of the object at which it is resting
you should not expect the list to output
when you print the array variable using System.out.println(abs);
then also you will get the same output
this is also because of the same reason that array is an object in java and printing it will print the hashcode

also you are getting the same output because whenever you modify the arrays or the lists using toArray or asList methods
then the changes are done directly in the original array or the list... the copy of the list is not created
hence the changes done int array or the list are reflected in both
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ mohitkumar gupta...

Your problem is related with Non - generics collection. A non - generics collection is quite happy to hold anything that is NOT a primitive. Use a Integer array instead of int array.

If I correct it,
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic