Re: Singly Linked LIst and Objects Newbie Question
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 12:51:46 -0400
Philipp Leitner wrote:
I might be missing something totally obvious here, but where in your
code are you setting the 'head' of the list? This is something that
should probably go into the block where you check for the 'first
value'.
Another sidenote: you should stick to the standard conventions of CS,
like that the first element of a list has the index '0', not '1' as in
your case (see for instance arrays, the java.util collections, ...)
What do you mean by "CS"?
Java arrays and implementations of java.util.List are zero-based in fact, not by convention. java.sql.PreparedStatement and ResultSet count parameters columns respectively from one, not zero. I'm not sure one can assert the existence of a convention.
It is enough, though, that the fact of arrays and java.util.Lists is that they index from zero. The advice to do likewise in classes that extend or wrap arrays or java.util.List is sound. Among other things, it eliminates the confusing and error-prone offsets by one that abound in the OP's code.
To the OP: your main() method ought to do something to display or otherwise prove that the contents of your list are what you expect them to be.
--
Lew
.
- Follow-Ups:
- Re: Singly Linked LIst and Objects Newbie Question
- From: Taria
- Re: Singly Linked LIst and Objects Newbie Question
- From: Arne Vajhøj
- Re: Singly Linked LIst and Objects Newbie Question
- References:
- Singly Linked LIst and Objects Newbie Question
- From: Taria
- Re: Singly Linked LIst and Objects Newbie Question
- From: Philipp Leitner
- Singly Linked LIst and Objects Newbie Question
- Prev by Date: Re: google
- Next by Date: Re: do I need "volatile" for HashMap? when I apply ReentrantReadWriteLock on it.
- Previous by thread: Re: Singly Linked LIst and Objects Newbie Question
- Next by thread: Re: Singly Linked LIst and Objects Newbie Question
- Index(es):
Relevant Pages
|
|