Creating a new equals() method help
Hello, I'm having trouble with the comparison of an array of football teams and an array of team names that may or may not be in the football team array. I have read both .txt files into their own arrays and parsed the team array with substring in order to isolate the team name. I know I can read both the search array and the team names individually because I tested it with a println. I think my problem is in the comparison "if" statement.
My output prints the names of each team on their own line and at the end it always says that it can't find each search term.
public void seqSearch()//Sequential(linear) search
int j=0, s;
//int m = j+1;
for(s=0; s<searchSize; s++)//increments through the search array
for(j=0; j<teamArray.length; j++)//increments through the team array
if(teamArray[j].getName().equals(search[s]))//I think this is where the problem is
System.out.println("Found " + teamArray[j].getName() + "after" + j + "searches.");
System.out.println(teamArray[j].getName());//prints through all of the names during each search for testing
if(j == teamArray.length-1)
System.out.println("Can't find " + search[s] + " after " + j + " searches");
Can't find Bills after 32 searches
Can't find Eagles after 32 searches
I'm pretty sure I have to create a new equals method but I don't understand how else I'm supposed to compare them other than as I have in the code above. teamArray[j].getName returns a string teamName and search is an array of type String so shouldn't each search[s] also be a string? If that is the case(both are strings) how else does one compare two strings besides the built in equals() method?
Any help would be much appreciated.