• Post Reply Bookmark Topic Watch Topic
  • New Topic

Linkedlist  RSS feed

 
Vallabhaneni Suresh Kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to get an address of each node in an linked list. I want to store those addresses in a file.
 
Joe Ess
Bartender
Posts: 9443
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No such thing as an "address" in Java. This avoids big problems in C and C++ associated with pointer arithmetic, buffer overruns and such.
And why would you save addresses to a file? When a program ends, the memory that was allocated goes away and your pointers would be invalid. Now, if you wanted to preserve the contents of the linked list, take a look at the Java Tutorial chapter on IO: Reading and Writing, especially the part about Object Serialization.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you mean a postal address? In which case the code might look like:



Jules
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!