Help me! java.lang.ArrayIndexOutOfBounds exception keeps coming up

Ok, here is my program. Its a very simple program to find the integer factors of an integer number.

[code][code]class NumFactorer {

public static void main (String arguments[]){

int divisor = 1;

int number = 9;

int z = number;

int result = 0;

double i = 0;

int s = 1;

int Resultarray[][] = new int[2][9];

while(divisor<(number/2)) {

i = number%divisor;

if(i == 0){

result = number/divisor;

Resultarray[1][s] = divisor;

Resultarray[2][s] = result;

}

divisor++;

s++;

}

System.out.println(Resultarray[1][1]);

}

This program compiles fine, but when I try to run it, it throws the java.lang.ArrayIndexOutOfBoundsException. Please help.

[772 byte] By [Ottobonna] at [2007-11-26 18:50:32]
# 1
Arrays are indexed from 0 so this value does not exist:Resultarray[2][s] = result;You have two options, index 0 or index 1. The size is 2 but the the last index is 1.Message was edited by: kikemelly
kikemellya at 2007-7-9 6:24:34 > top of Java-index,Java Essentials,New To Java...
# 2

>Its a very simple program

Right. Try this

package testing;

public class Test

{

public static void main(String[] args)

{

int number = 27216;

for (int i = 1; i <= number; ++i)

if (number % i == 0)

System.out.println(i);

}

}

#

duckbilla at 2007-7-9 6:24:34 > top of Java-index,Java Essentials,New To Java...
# 3
but i need it to store the values so i can call them with another block of code that i am writing. (eventually the program will factor quadratic equations)
Ottobonna at 2007-7-9 6:24:34 > top of Java-index,Java Essentials,New To Java...
# 4
oh my gosh it worked thank you so much.
Ottobonna at 2007-7-9 6:24:34 > top of Java-index,Java Essentials,New To Java...