Results 1 to 2 of 2
- 04-19-2012, 03:36 AM #1Member
- Join Date
- Apr 2012
- Rep Power
Calling a Method in all Objects of a Class
I am using a method that prints out information relating to one object, yet I need to print this information for all objects. Rather then writing object1.print(); object2.print(); etc etc, is there a way to just call them all at once, such as by using the class name?
Any advice would be appreciated, thankyou!
Re: Calling a Method in all Objects of a Class
You probably want a collection of objects such as putting them all into an ArrayList and call the method on all objects in the list via a for loop.
- By jlczuk in forum Advanced JavaReplies: 8Last Post: 04-18-2012, 04:58 PM
- By andrewche in forum New To JavaReplies: 5Last Post: 05-04-2011, 04:46 AM
- By Blah_ in forum New To JavaReplies: 5Last Post: 09-29-2009, 02:48 AM
- By CirKuT in forum New To JavaReplies: 29Last Post: 09-25-2008, 07:55 PM
- By kpedersen in forum Advanced JavaReplies: 4Last Post: 08-20-2008, 12:25 AM