PDA

View Full Version : cannot find method print() ???


WildChild
12-10-2006, 12:26 PM
This is my line of code:
public void list()
{
for(Account account : accounts) {
account.print();
System.out.println(); // empty line between items
}
}

When i compile the line "account.print();" is highlighted and i recieve an error: "cannont find symbol - method print()".

if i remove this segment of code the class compiles fine, argh! (i think the code is right).

Mink
12-10-2006, 01:29 PM
The compiler is telling you that it cannot find the method print() in the Account class. Check the class, and see if you actually have a print() method in it.

WildChild
12-10-2006, 01:48 PM
the previously mentioned segment of code was in my PhoneCompany Class, it is now working fine as I have added a print method to the Account class.

Why does it need to be in the Account Class, i would have thought a print method in any of the classes would work.

Thanks very much anyhow.

Mink
12-10-2006, 01:51 PM
You need a print() method int he Account class because you are trying to access a print() method from and object of that class.