Arrays- Showing the populated array.
Hey,
this is my first semester of Java, so it is all news to me.
My question Im sure isnt difficult to answer.
"Write a program that prompts the user for a value and creates an integer array of that size. Prompt for initial values to populate the array."
This is what I have so far:
import java.util.Scanner;
public class numbers
{
public static void main(String[] args)
{
int arrayLength;
int i;
int x = 0;
Scanner console = new Scanner(System.in);
System.out.print("Enter size of array: ");
arrayLength = console.nextInt();
int[] anArray = new int[arrayLength];
for (i = 1; i <= anArray.length; ++i)
{
System.out.print("Enter value #" + i + ": ");
anArray[x] = console.nextInt();
}
}
}
Now, I want to check if the numbers that I entered do in fact populate this array. How can I output them on the screen to check? Ive spent a few hours on this, my book doesnt cover it, it only covers arrays with a given population and given numbers such as "int[] anArray = {5, 10, 15, 20}". My for statement could be wrong also.
I would appreciate any feedback.
Thank you.

