Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing ArrayLists

 
Mike Drozz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to pass an ArrayList into a method and print all the info in the arraylist. here's my code so far:


i receive the following error:

thanks in advance, peoples
 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pls chk the code wht u have posted i think its not correct
chk from where ur getting DevEmployee
whats this??
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you calling the printAll on? It doesn't appear that printAll is a method of 'TestInheritance' and since TestInheritance doesn't extend anything it can't be a method of it's superclass. If you're calling it on the that instance then the code needs to be in the same class that contains it (or a subclass of it), if not you need to instantiate one and call it on that.
 
Mike Drozz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didnt print the whole code, but here it is anyways:

and i still get the same error as above. Thanks in advance.
[ August 09, 2003: Message edited by: Mike Dr ]
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said you need to call it on an instance of the class that contains the printAll method. You can't call printAll on TestInheritance because TestInheritance does not contain the printAll method nor is it a subclass of a class that does.
Either move the printAll method to the TestInheritance class, have the TestInheritance class extend DevEmployee, or create an instance of DevEmployee that you call printAll on.
 
Mike Drozz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think i get you, this is what i changed it to:

i get an error message saying:
 
Mike Drozz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahhhh it's cool, i found the problem. Thanks for your help, mate!
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eh.. yeah... good.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch Mike. I have never seen a last name of Dr before, it's usually an abbreviation for Doctor, so I ask you to please take a few moments to review JavaRanch's Naming Policy, and change your last name accordingly.
Thanks in advance,
-Barry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic