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 8433069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:17:22+00:00 2026-06-10T06:17:22+00:00

I was working on a way to change to length of some code. I

  • 0

I was working on a way to change to length of some code.

I had this:

    rects[1].setLocation(0, 0);
    rects[2].setLocation(100, 0);
    rects[3].setLocation(200, 0);
    rects[4].setLocation(300, 0);
    rects[5].setLocation(400, 0);
    rects[6].setLocation(500, 0);
    rects[7].setLocation(0, 50);
    rects[8].setLocation(100, 50);
    rects[9].setLocation(200, 50);
    rects[10].setLocation(300, 50);
    rects[11].setLocation(400, 50);
    rects[12].setLocation(500, 50);
    rects[13].setLocation(0, 100);
    rects[14].setLocation(100, 100);
    rects[15].setLocation(200, 100);
    rects[16].setLocation(300, 100);
    rects[17].setLocation(400, 100);
    rects[18].setLocation(500, 100);
    rects[19].setLocation(0, 150);
    rects[20].setLocation(100, 150);
    rects[21].setLocation(200, 150);
    rects[22].setLocation(300, 150);
    rects[23].setLocation(400, 150);
    rects[24].setLocation(500, 150);

And I changed it to this:

    for(int i = 1; i < 25; i++)
    {
        for(int j = 0; j < 550; j +=50)
        {
            for(int k = 0; k < 550; k +=50)
            {
                rects[i].setLocation(j, k);
            }
        }
    }

The problem is the latter doesn’t work, though it should. My question is, what is the problem? I’ve tried many ways of fixing the problem, but nothing works. I have to way to google this quesion, because I don’t know what the problem is. This is also a code from an applet, if that is noteworthy.

  • 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-10T06:17:23+00:00Added an answer on June 10, 2026 at 6:17 am

    Your loop should look like this:

    for (int i=0; i<24; i++) {
        int x = (i%6)*100;
        int y = (i/6)*50;
        //Array indexes start from 1, whereas this  
        //loop starts from 0, hence adjusting below
        rects[i+1].setLocation(x, y);
    }
    

    You don’t need three nested loops since you’re assigning to only one array.

    By the way, shouldn’t your array indexes for rects start from 0?

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

Sidebar

Related Questions

I'm working up a custom Xcode template, and I'd like to change the way
I can't find i smooth 100% working way to keep my app in the
I'm working my way through some ASP.NET MVC reading and I have a web
I'm still working my way through some pretty basic Actionscript programming (in Flex), and
In some of the code I'm working on, the author max AJAX calls to
I am working my way through some of the android developers tutorial, specifically the
Possible Duplicate: jasper ireport field length problem I'm working on this web application done
While working my way through the Android tutorials, I came across something I don't
I'm working my way through "Learning jQuery" (Third Edition). In Chapter 4: "Manipulating the
I'm working my way through displaying various data elements from parent & child data,

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.