c# Object reference not set to an instance of an object

using UnityEngine;
using System.Collections;

public class enemy_movement : MonoBehaviour {

		int i=0;
		int num=-1;
		int temp;
		public Transform[] patrolpoints;
		public Transform planetposition;
	public int movespeed;
	private int currentposition;
	public int size;
	GameObject[] enemy;
	GameObject PreFab;
	
	// Use this for initialization
	void Start () {
	
	
	PreFab=(GameObject)Instantiate(Resources.Load("enemy"));
	//currentposition=0;
	}
	
	
	
	
	// Update is called once per frame
	void Update () {
	
	
	
	if(num<2)
	{
	num=num+1;
	temp=random_value();
	
	//this is the error line


	enemy[num] = (GameObject)GameObject.Instantiate(PreFab, patrolpoints[temp].position, Quaternion.identity);
	
	
	
	}
		for(i=0;i<=num;i++)
		enemy<em>.transform.position=Vector3.MoveTowards(enemy_.transform.position, planetposition.position , movespeed*Time.deltaTime);_</em>

* }*

* int random_value()
_
{_
_
int num = Random.Range(0, patrolpoints.Length);_
return num;
_
}_
_
}_
i’m new to c#,building my first game on unity.
the error that i get is
NullReferenceException: Object reference not set to an instance of an object
_
(wrapper stelemref) object:stelemref (object,intptr,object)*_
enemy_movement.Update () (at Assets/scripts/enemy_movement.cs:50)
this code works for a single enemy ,but not for multiple that are created using an array.
any way to correct this or any better way to do this.
thanks.

There’s an uninitialized array.

 GameObject[] enemy;

change it to something like:

 GameObject[] enemy = new GameObject[3];