import java.util.Random;
public class WhyThisException
{
   public static void main (String args [])
	{
	   Random[] myRandomArray;
		
		myRandomArray = new Random [10];
	
	   // this loop will print out null  null  null   because none of
		// the Random objects in myRandomArray has been instantiated 	
		for (int i = 0; i < 3; i++)
		{
		  System.out.print (myRandomArray[i]+ "  ");
		}
	   
		int temp; 
		// next line will cause a NullPointerException 
		// temp = myRandomArray[1].nextInt();
		// This is because myRandomArray[1] has never been instantiated
		// so it doesn't exist as a Random object so it can't access
		// any of Random's methods (in this case nextInt();.
		
		
	   myRandomArray[1] = new Random(35);
		temp = myRandomArray[1].nextInt(10);
		System.out.println (temp);
	  
	 }
}