• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object Array and Linked list  RSS feed

 
Castulo Ruiz
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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?
 
Raymond Tong
Ranch Hand
Posts: 255
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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: 255
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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: 255
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!