• Post Reply Bookmark Topic Watch Topic
  • New Topic

toString method in vector.  RSS feed

 
Kelly Frasure
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to add a toString method to print out all of the elements in the vector. The code will not compile. This is my code. I don't understand why I'm getting this error. The problem is in the AccountList program.
-----------------------------------------------------------------

-----------------------------------------------------------------

-----------------------------------------------------------------
A:\BankProgram\AccountList.java:43: cannot resolve symbol
symbol : variable AcctRoster
location: class AccountList
return AcctRoster;
^
1 error

[This message has been edited by Kelly Frasure (edited July 22, 2001).]
(edited by Cindy to format code)

[This message has been edited by Cindy Glass (edited July 23, 2001).]
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Kelly.
The problem is, AcctRoster only has scope within the constructor.
Make this Vector an instance variable instead, and try it again.
Good luck,
Art
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!