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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:59:56+00:00 2026-05-26T02:59:56+00:00

I made one class for my object: public class circles { int coor_x; int

  • 0

I made one class for my object:

    public class circles {

    int coor_x;
    int coor_y;

    int ray;


    public circles(int coor_x, int coor_y, int ray) {
    this.coor_x=coor_x;
    this.coor_y = coor_y;
    this.ray =ray ;

    }



  public int getCoor_x() {
        return coor_x;
    }

    public int getCoor_y() {
        return coor_y;
    }

      public int getRay() {
        return ray;
    }



    public void setCoor_x(int coor_x){
    this.coor_x=coor_x;
    }

     public void setCoor_y(int coor_y){
    this.coor_y=coor_y;
    }

      public void setRay(int ray){
    this.ray=ray;
    }


}

But when I wont to make an array of it and fill it with a for, with this code:

 int coor_x=2;
    int coor_y=2;
    int ray=2;
    int i = 0;    

    circles circles_test[]=new circles[10];


    for(i=0; i<=circles.length;){


        circles_test[i]=new circles(coor_x, coor_y, ray+i); //line 30
        System.out.println("Ray of circles: "+circles_test[i].getRay());
    i++;
    }

it works but with errors:
Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 10
at circlesObjectCreator.main(circlesObjectCreator.java:30)
Java Result: 1

What I am doing wrong? Is a better why to it? Please help and thank you.

  • 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-26T02:59:56+00:00Added an answer on May 26, 2026 at 2:59 am

    You’re accessing an array with 10 elements, indexed 0-9, with an index running from 0 to the array length, 10, because of the i <= circles.length. You want to use i < circles.length.

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

Sidebar

Related Questions

suppose I have an object like this: class Spline { public: Spline(std::size_t const dim);
I made a class library, and put it in GAC. It has one C#
I made this bash one-liner which I use to list Weblogic instances running along
I made this code with jQuery to fade images ( but not the one
I have a list of the following object: public class userReview { public long
After I made a public static class has some public static variables when I
I think this explains my question well enough: public class Model { public static
Assume the following entity classes: public class Player { public virtual int ID {
I have just refactored a colleague's code that, roughly, looked like this... public class
public partial class Form1 : Form { MyClass myClass = new MyClass(one, two); public

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.