Sort Game NULLPOINTEREXCEPTION IN LINE 36 WHY?

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int min = scan.nextInt();
int n = scan.nextInt();
Employee[] arr = new Employee[n];
for(int i=0;i<n;i++){
String name = scan.next();
int salary = scan.nextInt();
if(salary>=min){
arr[i] = new Employee(name,salary);
}
}

	display(mergeSort(arr,0,arr.length-1),min);
}
public static Employee[] mergeSort(Employee[] arr,int start,int end){
	if(start == end){
		Employee[] base = new Employee[1];
		base[0] = arr[start];
		return base;
	}
	int mid = (start+end)/2;
	Employee[] left = mergeSort(arr,start,mid);
	Employee[] right = mergeSort(arr,mid+1,end);
	Employee[] out = mergeTwoArray(left,right);
	return out;
}
public static Employee[] mergeTwoArray(Employee[] left, Employee[] right){
	int i = 0;
	int j = 0;
	int idx =0;
	Employee[] out = new Employee[left.length + right.length];
	while(i < left.length && j<right.length){
		if(left[i].salary<right[j].salary){
			out[idx] = right[j];
			idx++;
			j++;
		}else if(right[j].salary<left[i].salary){
			out[idx] = left[i];
			idx++;
			i++;
		}else{
			if(left[i].name.compareTo(right[j].name)>0){
				out[idx] = right[j];
				idx++;
				j++;
			}
			else{
				out[idx] = left[i];
				idx++;
				i++;
			}
		}
	}
	while(i<left.length && j==right.length){
		out[idx] = left[i];
		idx++;
		i++;
	}
	while(j<right.length && i==left.length){
		out[idx] = right[j];
		idx++;
		j++;
	}
	return out;
}

public static void display(Employee[] arr, int min){
	for(Employee val : arr){
		
			System.out.print(val.name+ " "+ val.salary);
		
		System.out.println();
	}
}

}
class Employee{
String name;
int salary;
public Employee(String name, int salary){
this.name = name;
this.salary = salary;
}
}

@Vaibhav-Garg-1998823966894298
Please initialize employee array before using it as it is having all elements as null.
The initialization at each index is to be done through for loop.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.