I'm going from learning C/C++ to learning Java: What the heck is this? -
i saw implementation of linked list in java (http://www.danielacton.com/data-structures/linked-list/java/), , here's node looked like:
private class listnode { private object data; private listnode next; } what heck that????
the size of listnode must infinity bytes, if think logic here. shouldn't listnode hold address of listnode?
that's 1 of confusing things going c++ java. in java,
private listnode next; declares reference variable, closely compared listnode& reference in c++. 1 way of creating linked list in java - have node store data , reference next item.
note in java, default value (if uninitialized) of next null.
for take blow way think, have be:
private listnode next = new listnode(); which result in stackoverflowerror.
Comments
Post a Comment