Tim Holloway wrote:First of all, Java does not have "pointers". Despite the fact that it has a "NullPointerException". Java works with references, and while you can use pointers to reference stuff, references themselves are not pointers in Java.
Thank you for clarifying. Our professor calls the references pointers, but I didn't realize this was not great terminology for expressing the utility.
Tim Holloway wrote:
A multi-node list element with named "pointers", however, is not a good fit for Java. It could be done in several ways, including having the list node paired with a Map of named references, but that's a bit of overhead.
More commonly one would have the node associated with an object array and use integer value indexing. You could then use a Java Iterator, a for-each, or one of the newer language constructs to pass over the array's elements.
You could also associate a List node with a Collection. Which is what the Node-with-Map solution I iniitally suggested does.
Then again, you can do a lot with binary and trinary trees and simply use an existing library.
Thanks for explaining that- we aren't allowed to use any existing libraries except java.IO, so we have to build our own structures. I'm curious how a multilinked list could use an integer array, do you mean so that each array element held the number of pointers/links for the associated nodes?