If I use l.search("Hi"); the code will run fine but if I pass String s to search method, it will prompt an error NullPointerException
System.out.print("Search: ");
String s = scan.next();
l.search(s);
public void search(String name){
Node current = tail;
while(current != null && current.name != name){
current = current.previous;
}
if(current.name == name){
System.out.println("Item found.");
}
}