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

  • Home
  • SEARCH
  • 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 7795955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:13:20+00:00 2026-06-01T23:13:20+00:00

Now, Im currently wrinting a simple graphics program. In it I hava a Array

  • 0

Now, Im currently wrinting a simple graphics program.
In it I hava a Array called m_ball.

Now, m_ball is suposed to contain up to 20 instances of the class Ball.

Rigth now I do this by the following code =

        Ball m_activeBall0 = new Ball();
        Ball m_activeBall1 = new Ball();
        Ball m_activeBall2 = new Ball();
ect...
        m_ball[1] = m_activeBall0;
        m_ball[2] = m_activeBall1;
        m_ball[3] = m_activeBall2;
ect...

Now thats all sound and well.
But aint it posible to do it in a for loop.
some thing like this =

        for(int i = 0; i <m_ball.length;i++) {
            Ball m_activeBall[i] = new Ball();
            m_ball[i] = m_activeBall[i];
        }

or have I lost it?

I simply cant seem to find a way to do this.

I tried Google, but cant seem to find the answer.

Oh.. yea. forgot to add. its Java.

  • 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-06-01T23:13:21+00:00Added an answer on June 1, 2026 at 11:13 pm
    Ball[] m_ball = new Ball[20];
    
    for(int i = 0; i < m_ball.Length; i++)
    {
       m_ball[i] = new Ball();
    }
    

    I wrote this in C# but I’m pretty much sure it’s same with Java. Cheers. 🙂

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

Sidebar

Related Questions

Right now, I'm currently serializing a class like this: class Session { String setting1;
Currently I am writing a program for an introductory Java class. I have two
I'm currently writing a ToDo-Script for a project i have running. Now there is
I'm a newbie on grails. I am now currently working on my scaffolding templates
Right now I currently using transactional replication with updatable subscription. Is there any ways
I have started to try out noSQL databases now and are currently testing out
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
I am currently working on ClearCase and now migrating to GIT. But we need
I am currently learning the zsh and now I wanted to use strftime but
I am currently using ASP.NET MVC1 in my project but now i am planing

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.