2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by JamesCherrill
0

Can't edit the post....

Or could I not ask the user what book he's looking for and then....

if (NameList1.contains("JName of Book")) {
    // code to execute if book is in the list
}

About the traversing..

ref = ref.next;

Node ref = mylist;
while (ref != null)
{
System.out.println(ref.value);
ref = ref.next
}

That's what the book gives me. SOmething like that ?+

Edited by Torf

0

How do I exactly do this, though.

//get user input 
    input = JoptionPane.showInputDialog("Enter the name of the book:");

    variable = String.parseString(variable);

    if (LinkedList.contains("Name of Book")) {
    JOptionPane.showMessageDialog(null, "Result ");
    }

Is LinkedList.contains correct? I need a variable, I guess. How do I do this here with a linked list?

0

If you are using the Java API LinkedList class then yes, but if you are writing your own LinkedList class then you have to use a loop to search all the nodes for the value you want

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.