• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Conversion toArray and asList problem

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic