loading prefabs in an array

hi need to load all the prefabs in the resources folder into an array. the script is below. the problem is when i run the script it shows an error message as below. i dont know where am making mistake. need help on how to load the prefabs.

NullReferenceException: Object reference not set to an instance of an object
runtime.Start () (at Assets/scripts/runtime.cs:22)

using UnityEngine;
using System.Collections;

public class runtime : MonoBehaviour {

	public int rows;
	public int columns;
	public int n = 3;

	int initialPositionX = -5;
	int initialPositionY = 5;
	float bufferSpace = 1.5f;

	public Transform prefab;
	public GameObject[] items;
	// Use this for initialization
	void Start () {
		items = new GameObject[];
	    items = Resources.LoadAll("prefabs")as GameObject[];
		int index = Random.Range(0, items.Length);
	// Update is called once per frame
	void Update () {

	public void cardCreation(int cardIndex)
	      float spaceBetweenCards = prefab.transform.localScale.x;

		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)

				Instantiate(items[cardIndex], new Vector3((j*bufferSpace+spaceBetweenCards),(i*bufferSpace+spaceBetweenCards),0),

In your this line

items = new GameObject[];

your array is not initialized. You should actually get an error stating:

CS1586: Array creation must have array
size or array initializer

So you can set the length of your array dynamically as:

items = new GameObject[Resources.LoadAll<GameObject>("prefabs").Length];

Or you can also specify the value for length there directly.

And you populate it using:

 items = Resources.LoadAll<GameObject>("prefabs")as GameObject[];

Also remember there should be a folder names ‘prefabs’ inside your Resources folder where all your prefabs will be stored. This ‘prefabs’ is the argument you pass to your Resources.LoadAll method.

It’s possible, depending on the number of Prefabs that have to be loaded, that not all could be loaded into the array before cardCreation starts to try and access prefabs from the array. Maybe try starting cardCreation as a Coroutine with a 1-second delay or something. In anyway, if you don’t call cardCreation at all, is the array successfully filled with Prefabs?