# Thread: Fill in the blank code for arrays

1. Member
Join Date
Apr 2011
Posts
1
Rep Power
0

## Fill in the blank code for arrays

Hi,

I'm new to the forum and the online university I go to has fill in missing code type assignments. I've spent a ton of hours this week trying to learn arrays and how they work, but I'm stuck on the first part of our assignment and am not sure what code to fill it in with. Any help and explanation would be appreciated.

// Application Reverse reads numbers into an array
// and prints them out in reverse order.
import java.util.Scanner;
import java.io.*;
public class Reverse
{
public static void main(String[] args) throws IOException
{
final int MAX = 10;
Scanner inFile =
int[] numbers;
numbers = new int[MAX];

int value;
int index;
for (index = 0; index < numbers.length; index++)
{
// FILL IN Code to read value
// FILL IN Code to store value into numbers
}

for (index = MAX - 1; index >= 0; index--)
System.out.println(
inFile.close();
}
}

2. Welcome to the forums, and I hope I can help you out.

Lets first try to think about what this does
Java Code:
```for (index = 0; index < numbers.length; index++)
{
// FILL IN Code to read value
// FILL IN Code to store value into numbers
}```
This is going to repeat some task x times, in this case x is equal numbers.length. It is going to start at 0, and go to numbers.length - 1, which is how array indexing works.

Java Code:
```int[] x = {1, 2, 3, 4, 5}; //length of 5
//indexes
x[0] == 1
x[1] == 2
x[2] == 3
x[3] == 4
x[4] == 5```
So you are going to be evaluating the block numbers.length times. You want to first receive input from the user and then assign the index to that value.

Lets see what you can come up with before we go any further. I suggest you check out the following link: Using a scanner to read a file

Post up what you come up with and please use code tags.

[code]