NullPointer Exception. Please check the code

import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int a = scn.nextInt();
class employee{
String name;
int salary;
}

    employee[] emp = new employee[a];
    for(int i=0; i<a; i++){
        emp[i].name = scn.nextLine();
        emp[i].salary = scn.nextInt();
        scn.nextLine();
    }

    for(int i=0; i<a-1; i++){
        for(int j=0; j<a-i-1; j++){
            if(emp[j].salary<emp[j+1].salary){
                employee temp = emp[j];
                emp[j]=emp[j+1];
                emp[j+1]=temp;
            }
            if(emp[j]==emp[j+1] && emp[j].name.compareTo(emp[j+1].name)<0){
                employee temp = emp[j];
                emp[j]=emp[j+1];
                emp[j+1]=temp;                                       
            }
        }
    }

    for(int i=0; i<a; i++){
        if(emp[i].salary<n)
            break;
        System.out.println(emp[i].name + " " + emp[i].salary);
    }
}

}

@vishesh
Please add the following code below emp array.

employee[] emp = new employee[a];
for(int i=0;i<emp.length;i++) {
emp[i]=new employee();
}
Reason:The employee array is by default having null declaration at every index,which needs to be initialised.

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.