Help with search and remove in playerroster

Please post your questions and the code you are having problems with.

Okay here is the code

public void Search()
   {
      System.out.println("Who do you want to find? ");
      System.out.println("Last Name: ");

      String Value;
      doubleNode Temp;
      Temp = list.getBegin();

      int k = 0;
      String [] lis = {"","","","","","","","","","","","","","","","","","","",""};
      String [] result = {"","","","","","","","","","","","","","","","","","","",""};


      while( (Value = Temp.getValue()) != null)
      {
         lis [k] = Value;
         String [] tokens = lis [k].split(" ");
         result [k] = tokens[3];
         Temp = Temp.getNext();
         k++;
         if(Temp == null)
            break;
      }

      String Name = Input.next();
      int index = Arrays.binarySearch(result, Name);

      if (index >= 0 )  
         System.out.println(Name + " is in the Roster");  
      else  
         System.out.println(Name + " is not in the Roster.");  

   }

It seems that the problem has something to do with the binary search, but I don't know what it is. The idex result is always -21.

Can you post the output from the program. Have you read the API doc for the binareySearch method to see what values it returns? Why do you think -21 is wrong?
When does the array; result get any non empty values? Have you printed out the contents of result to see what it is loaded with? How many elements does it have? Change the number of elements and see if the value of index changes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.