Arrays of objects

So I have an array of objects of a bank account. I need to have a search method that will search the array based on the account's name and return the account's information.

public String linearSearch (Banking[] bankArray, String key,int counter)

{

for (int i = 0; i < counter; i++)

{

if (key.equals(bankArray[i]).getAccountName)

return bankAccount[i].getAccountName;

}//End For

return"Nothing Found";

}//End linearSearch

This method (is supposed to) search the array based on the "getAccountName" field of the objects in the array...but it

s not working. is there another comparison method I should be using besides .equal?

[1133 byte] By [Imbriuma] at [2007-10-3 11:31:53]
# 1

> but it s not working

In what way is it "not working"? In this case I can work it out myself, but in general it pays to describe your problem as precisely as possible.> if (key.equals(bankArray[i]).getAccountName)

You've put a ) in the wrong place. What do you want to compare with key?

YAT_Archivista at 2007-7-15 13:58:37 > top of Java-index,Java Essentials,New To Java...
# 2

What do you mean by "not working"?

Anyway, the code you posted does not compile because it contains a number of syntax errors. It's not valid Java code. You're making a lot of mistakes that have to do with braces. Try this:

if (key.equals(bankArray[i].getAccountName()))

return bankArray[i].getAccountName();

jesperdja at 2007-7-15 13:58:37 > top of Java-index,Java Essentials,New To Java...
# 3
The user enters the name of an account, and then the program calls this method. In the method I want to search through each bank account in the array searching the "getAccountName" field to see if it matches the name entered by the user.
Imbriuma at 2007-7-15 13:58:37 > top of Java-index,Java Essentials,New To Java...
# 4
jesperdj, thanks, that fixed it. I'm so tired I just keep making stupid mistakes.
Imbriuma at 2007-7-15 13:58:37 > top of Java-index,Java Essentials,New To Java...