This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes linked list problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "linked list problem" Watch "linked list problem" New topic

linked list problem

Pepo moussa
Ranch Hand

Joined: Mar 20, 2008
Posts: 36
hello i got a problem with this method which should read txt file and insert it into unsorted lined list but every time i try to print the list it give me empty list ,i tried the append method and it works fine anyone can help.

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

Since "RoomUnsortedList" is not a standard class, I can't be sure, but I think your problem is here:

while ( i < list.getLength() && line != null )

since "i" starts at zero, and I'll assume "list" starts out empty, this loop condition is false the first time, and so no append() calls are ever made.

[Jess in Action][AskingGoodQuestions]
Pepo moussa
Ranch Hand

Joined: Mar 20, 2008
Posts: 36
well you were right...i feel so stupid now :S lol anyway thank you
[ April 01, 2008: Message edited by: I moussa ]
I agree. Here's the link:
subject: linked list problem
jQuery in Action, 3rd edition