NullReferenceException: Object reference not set to an instance of an object animation ,I am not new to unity 5. I am new to C#.

Hell. I am new to C# and am trying to build my first full game. I am trying to get an animation to play but am getting the same error “NullReferenceException: Object reference not set to an instance of an object axeAnimation.new & axeAnimation.update” here is the code. using UnityEngine;
using System.Collections;

public class axeAnimation : MonoBehaviour {
public GameObject axeGameObject;
Animator anim;
int swingHash = Animator.StringToHash(“swing”);
// Use this for initialization
void Start () {
anim.GetComponent ();
}

// Update is called once per frame
void Update () {
	if (Input.GetKeyDown(KeyCode.Mouse0))
	{
		Debug.Log ("Test");
	//18	\\ anim.SetTrigger("Default Take");
	}
}

}
"
The error is on line 18 it says. Please help me out. ,

If the Animator is actually on the same gameobject that the axeAnimation script is on, the correct way of getting the component is:

anim = GetComponent<Animator>();

If, on the other hand the Animator is on different gameobject, you’d need to find the gameobject first and then get the component off of it.

The reason this error happens, is that you do not get the component that you need with the line

anim.GetComponent();

so your anim variable is null (as in it doesn’t have anything assigned to it). Then, on line 18 you are trying to access SetTrigger() method, but you are trying to do so on essentially nothing.