Results 1 to 2 of 2
  1. #1
    Tman is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default 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!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default 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.

Similar Threads

  1. Replies: 8
    Last Post: 04-18-2012, 04:58 PM
  2. Calling a method from another class
    By andrewche in forum New To Java
    Replies: 5
    Last Post: 05-04-2011, 04:46 AM
  3. Child-Class Calling a Method in a Parent-Class
    By Blah_ in forum New To Java
    Replies: 5
    Last Post: 09-29-2009, 02:48 AM
  4. Replies: 29
    Last Post: 09-25-2008, 07:55 PM
  5. Calling a method on original class from created class
    By kpedersen in forum Advanced Java
    Replies: 4
    Last Post: 08-20-2008, 12:25 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •