Can't play an animation from the Animator

i always get this error when i try to play the animation:

NullReferenceException: Object reference not set to an instance of an object

      using UnityEngine;
      using System.Collections;

      public class Akscript : MonoBehaviour {
      Animator anim;

// Use this for initialization
void Start () {

    anim.GetComponent<Animator>();
}

// Update is called once per frame
void Update () {

    if(Input.GetKeyDown("1"))
    {
        anim.SetBool("IsRunning", true);
    }

}

}

Never mind, just put a “Public” in front of Animator anim; and it’ll appear in the inspector, then just select your game object