• 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

Object Array and Linked list

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So i have an ADT of a Doubly linked list.
I want to able make an array of objects that point to the list.

for example,

how will i be able to access the list again? is this possible?
 
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Castulo Ruiz wrote:So i have an ADT of a Doubly linked list.
I want to able make an array of objects that point to the list.

for example,

how will i be able to access the list again? is this possible?


If you have assigned A (your doubly linked list) to row[0], you can access your list from row[0].
What is your problem?
When you retrieve row[0], you got an Object instead of List?

You may want to check "Type Casting" and "Generics".
 
Castulo Ruiz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to be able to access the how would i go about printing the list A from the array?

I tried



that does not work because that just prints out the location.
I also want to change the objects inside the linked list

not sure how to do this.
Thank you in advance.
 
Raymond Tong
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Castulo Ruiz wrote:I want to be able to access the how would i go about printing the list A from the array?

I tried



that does not work because that just prints out the location.
I also want to change the objects inside the linked list

not sure how to do this.
Thank you in advance.


There is nothing to do with Array because you are referring to an array element (i.e. List).
So, check the List API.
http://download.oracle.com/javase/6/docs/api/java/util/List.html
You may want to iterate over the List and print the elements in your preferred format.
Again, to add, remove, modify elements in the list, you can found details in API doc.
 
Castulo Ruiz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, but is there a way to just store the linked list in the object array and later reference it?

Is it possible to do the follwing?


I have tried it, but i think i might be doing something wrong..
 
Raymond Tong
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Castulo Ruiz wrote:Alright, but is there a way to just store the linked list in the object array and later reference it?

Is it possible to do the follwing?


I have tried it, but i think i might be doing something wrong..


what java version are you using?
As I have mentioned, check "type casting" and "Generics".
Actually your IDE or the compiler already told you the problem you are facing.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic