Hello everyone! So I have to do this project for computer science class. We have to make a class that generates 50 odd numbers in order starting at 1 and stores them in an array of 50 int elements. Then we have to arrange the numbers we get so that there are only five in each row. Don't worry about the second part I only need help on the first! The code compiles fine but it always throws an arrayindexoutofboundsexception at the underlined line down there. Can anyone help me?
/**
* Write a description of class arrays here.
*
* @author
* @version 1/31/2011
*/
public class arrays
{
public static void main (String [] args)
{
int k, i;
int [ ] odds = new int [50];
for (i = 0; i <= odds.length; i++)
{
for (k = 1; k <= 99; k+=2 )
{
[B][U]odds[i] = k;[/U][/B]
}
System.out.println(odds[i]);
}
}
}