File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Printing ArrayLists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printing ArrayLists" Watch "Printing ArrayLists" New topic
Author

Printing ArrayLists

Mike Drozz
Greenhorn

Joined: Aug 09, 2003
Posts: 9
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

Joined: Jun 16, 2003
Posts: 121
pls chk the code wht u have posted i think its not correct
chk from where ur getting DevEmployee
whats this??


SCJP 1.2
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
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

Joined: Aug 09, 2003
Posts: 9
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

Joined: Jul 15, 2003
Posts: 1078
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

Joined: Aug 09, 2003
Posts: 9
i think i get you, this is what i changed it to:

i get an error message saying:
Mike Drozz
Greenhorn

Joined: Aug 09, 2003
Posts: 9
ahhhh it's cool, i found the problem. Thanks for your help, mate!
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Eh.. yeah... good.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing ArrayLists