Yes I am just trying to store the 10 values in the array to be
0 1 2 3 4 5 6 7 8 9
and when I use the program it prints out differently then how i expected.
CODE
public class Assignment2
{
public static void main(String[] args)
{
int[] intArray = new int[10];
for (int i=0; i<=intArray.length; i++)
{
intArray[i] = i;
System.out.println(intArray[2]);
}
}
}
In my terminal the output is
0 0 2 2 2 2 2 2 2 2 , so I understand that the output will print 0 until it actually gets to the number I try to call and will keep printing until it gets to the 10th element. How do I make it so that the output will only be the number I want.
Also instead of
CODE
for (int i=0; i<=intArray.length; i++)
shouldnt it be
CODE
for (int i=0; i<=intArray.length-1; i++)
This post has been edited by soccerizzy26: 23 Sep, 2008 - 07:46 AM