[SOLVED] [newbie] java.lang.NullPointerException
I'm getting a Null.PointerException when I try to iterate through the array.
:confused:
Code:
import java.util.*;
public class TestFour {
public static void main(String[] args) {
try {
Integer[] arrayOne = new Integer[100];
/*
Generate random numbers and iterate through
the array assigning a random number
within arrayOne[]
*/
Random randomNumber = new Random(1000);
for (int i : arrayOne ) //breaks here...
{
//arrayOne[i] = randomNumber.nextInt();
arrayOne[i] = 1;
}
//iterate through array and display contents
for (int i : arrayOne )
{
System.out.println(i);
}
}
catch (AssertionError ex)
{
System.out.println(ex.toString() + ": variable has a " + ex.getMessage() + " value.");
}
}
}
NOTE: It would be nice to have html tags (e.g. <code> </code> that distinguish code snippets from text.