searching linked list for match
<p>I am trying to search a linked list for a match but am always getting false. Here is my code:</p>

<p>List is filled infile is </p>

<pre><code> try
        {
            BufferedReader infile =
                new BufferedReader(new FileReader("C:\\videoDat.txt")); .....

       public static void createVideoList(BufferedReader infile,
                                       VideoList videoList)
                                       throws IOException
    {
        String  title;
        String  star1;
        String  star2;
        String  producer;
        String  director;
        String  productionCo;
        int   InStock;



        title = infile.readLine();
 //If the title exists then there is the rest
        while ((title=infile.readLine()) != null)   {
            // Fill Linked list
          star1=infile.readLine();
          star2=infile.readLine();
          producer=infile.readLine();
          director=infile.readLine();
          productionCo=infile.readLine();
          InStock=infile.read();
          VideoElement MovieObject=new VideoElement();
          MovieObject.setVideoInfo(title,star1,star2,producer,
          director,productionCo,InStock);
            videoList.addToList(MovieObject);
            title=infile.readLine();
        }//end while
    }//end createVideoList
</code></pre>

<p>Search using equals method:</p>

<pre><code>public boolean searchVideoList(String title)
{

    for(VideoElement x:VideoList)
    {
        if(x.equals(title))
        {
            return true;
        }

    }
        return false;


}//end searchVideoList 
</code></pre>

<p>calling search from main method:</p>

<pre><code>System.out.print("Enter the title: ");
                        title = in.readLine();
                        System.out.println();
                        if(videoList.searchVideoList(title)==true)
                            System.out.println("Title found.");
                        else
                            System.out.println("Video not in store.");
                        break;
</code></pre>

<p>Sorry I didnt even realize it was using the overided equals method from VideoElement which was provided for us by the teacher:</p>

<pre><code>  public boolean equals(DataElement otherElement)
    {
        VideoElement temp = (VideoElement) otherElement;
        return (videoTitle.compareTo(temp.videoTitle) == 0);
    }
</code></pre>

<p>I am always getting the video not in store because the searchvideolist always returns false at the end. But if I remove that it tells me I need to return something.. What to do.. </p>
