title: Linked List, searching through
body: <p>My teacher gave us a practice assignment that deals with Linked Lists I got the code for the search and searchhelper, but I am having trouble actually initializing the search. How might I go about that? I have tried prompting the user for a variable and then throwing that through the search method but I get an error "The method search(T) in the type List_3 is not applicable for the arguments (Integer)"</p>
  
  <p>The program has to: create a linked list, prompt the user for a value to search for, use the method search that recursively searches a linked-list object for a specified value. The method should return a reference to the value if it’s found; otherwise, it should return null.</p>
  
  <pre><code> import java.util.Scanner;
  
  
  class ListNode&lt; T &gt; 
  {
     T data; 
     ListNode&lt; T &gt; nextNode;
  
  
     ListNode( T object ) 
     { 
        this( object, null ); 
     } 
  
     ListNode( T object, ListNode&lt; T &gt; node )
     {
        data = object;    
        nextNode = node;  
     } 
  
  
     T getData() 
     { 
        return data; 
     } 
  
  
     ListNode&lt; T &gt; getNext() 
     { 
        return nextNode;
     } 
  } 
  
  
  public class List_3&lt; T &gt;
  {
     private ListNode&lt; T &gt; firstNode;
     private ListNode&lt; T &gt; lastNode;
     private String name; 
  
     public static void main( String[] args )
     {
        Scanner scan = new Scanner(System.in);
        int result;
        List_3&lt; Character &gt; list1 = new List_3&lt; Character &gt;();
        Integer number;
  
        list1.insertAtFront( '3' );
        list1.insertAtFront( '4' );
        list1.insertAtBack( '5' );
        list1.insertAtBack( '6' );
        list1.insertAtFront( '2' );
        list1.insertAtFront( '1' );
        list1.insertAtBack( '7' );
        list1.insertAtBack( '8' );
        list1.insertAtFront( '0' );
        list1.insertAtBack( '9' );
  
        list1.print();
        System.out.println("Please enter a value to search for: ");
        number = scan.nextInt();
        result = search(number);
     }
  
     public List_3() 
     { 
        this( "list" ); 
     } 
  
  
     public List_3( String listName )
     {
        name = listName;
        firstNode = lastNode = null;
     } 
  
  
     public void insertAtFront( T insertItem )
     {
        if ( isEmpty() ) 
           firstNode = lastNode = new ListNode&lt; T &gt;( insertItem );
        else
           firstNode = new ListNode&lt; T &gt;( insertItem, firstNode );
     } 
  
  
     public void insertAtBack( T insertItem )
     {
        if ( isEmpty() )
           firstNode = lastNode = new ListNode&lt; T &gt;( insertItem );
        else
           lastNode = lastNode.nextNode = new ListNode&lt; T &gt;( insertItem );
     } 
  
  
     public T removeFromFront() throws EmptyListException
     {
        if ( isEmpty() ) 
           throw new EmptyListException( name );
  
        T removedItem = firstNode.data; 
  
  
        if ( firstNode == lastNode )
           firstNode = lastNode = null;
        else
           firstNode = firstNode.nextNode;
  
        return removedItem; 
     }
  
  
     public T removeFromBack() throws EmptyListException
     {
        if ( isEmpty() ) 
           throw new EmptyListException( name );
  
        T removedItem = lastNode.data; 
  
  
        if ( firstNode == lastNode )
           firstNode = lastNode = null;
        else 
        { 
           ListNode&lt; T &gt; current = firstNode;
  
  
           while ( current.nextNode != lastNode )
              current = current.nextNode;
  
           lastNode = current; 
           current.nextNode = null;
        } 
  
        return removedItem; 
     } 
  
     public boolean isEmpty()
     { 
        return firstNode == null;
     }
  
     public void print()
     {
        if ( isEmpty() ) 
        {
           System.out.printf( "Empty %s\n", name );
           return;
        } 
  
        System.out.printf( "The %s is: ", name );
        ListNode&lt; T &gt; current = firstNode;
  
  
        while ( current != null ) 
        {
           System.out.printf( "%s ", current.data );
           current = current.nextNode;
        } 
  
        System.out.println();
     } 
  
  
     public T search( T input )
     {
        return searchHelper( input, firstNode );
     } // end method search
  
  
     private T searchHelper( T input, ListNode&lt; T &gt; node )
     {
        if ( node == null )
           return null;
        else if ( node.getData().equals( input ) )
           return node.getData();
        else
           return searchHelper( input, node.getNext() );
     }
  
  } 
  </code></pre>