Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6613389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:12:46+00:00 2026-05-25T20:12:46+00:00

I have created two classes and I am trying to invoke a constructor(with argument)

  • 0

I have created two classes and I am trying to invoke a constructor(with argument) and a method. I find it easy if I just use an object.

My Goal :

  1. To invoke the same method by using 3 objects.
  2. Use ArrayList to invoke the method 3 times.

My Homework:
I did google a bit. I happen to end with explanation of ArrayList and certain examples of it. I did not find examples which I think I need i.e. using ArrayList with Objects(like my citation).

public class DrawGraphics
{
    BouncingBox box;

    /** Initializes this class for drawing. */
    public DrawGraphics()
    {

            box = new BouncingBox(200, 50, Color.green);

            box.setMovementVector(1, 1);
    }
//..................
//................
}

Thank you for those who try to help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:12:47+00:00Added an answer on May 25, 2026 at 8:12 pm

    Continuing with your example this might give you an idea of what Lists can be used for:

    // Let's create an ArrayList that will contain the bouncingboxes
    List<BouncingBox> boxList = new ArrayList<BouncingBox>();    
    
    // Let's create 5 of them and add them to the end of the List
    for (int ii=0;ii<5;ii++) {
        boxList.add(new BouncingBox(200, 50, Color.green));
    }
    
    // Iterate over the List we just created with the enhanced for - the method will
    // be called on all objects in the List.
    for (BouncingBox box : boxList) {
        box.setMovementVector(1, 1);
    }
    

    Is this what you were looking for?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

good morning, I was trying the SharedPreferences Class and I have created two classes,
Alright so I'm trying to create a method called: setIncrement(). I have two classes
I'm having trouble trying to implement a shared method/property between two classes created by
I have created a debugger visualizer in VS2008. There are two classes i've made,
Say I have two classes created work and workItem. CWorker *work = new CWorker();
I have two classes Teacher and Student . I am trying to get teacher
Im trying to call an IBAction Method in two classes that is called whenever
I have a question. There are two classes: A and B. A creates object
I have created two forms in my Windows Application. One Form acts as a
I have created two files: tunables.h #ifndef TUNABLES_H #define TUNABLES_H void tunables_load_conservative(); void tunables_load_aggressive();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.