File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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: 24199

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
It's not a secret anymore!