Whenever I try to run this code:
import java.util.Scanner;
public class KCFRodriguez2019101507 {
Scanner sc = new Scanner(System.in);
static String empName, position, status;
static int empNo, salaryReg, salaryCon, year, deduction, netPay;
static float deduct;
@SuppressWarnings("null")
public static void main(String[] args) {
@SuppressWarnings({ "unused", "resource" })
Scanner sc = new Scanner(System.in);
String a = "Employee Name:";
String b = "Status:";
String c = "Position Title:";
String d = "Employee Number:";
String e = "Regular Salary:";
String f = "Contractual Salary:";
String g = "Year Hired";
System.out.println(a);
Scanner entry = null;
empName = entry.nextLine();
System.out.println(b);
status = entry.nextLine();
System.out.println(c);
position = entry.nextLine();
System.out.println(d);
empNo = entry.nextInt();
System.out.println(e);
salaryReg = entry.nextInt();
System.out.println(f);
salaryCon = entry.nextInt();
System.out.println(g);
year = entry.nextInt();
}
}
I get an error saying that "exception in thread 'main'", so I cant compile the code. I'm fairly new to java, so I don't know how to fix this. I'm trying to make a program that allows the user to enter Employee data.
Error Code: Employee Name: Exception in thread "main" java.lang.NullPointerException at KCFRodriguez2019101507.main(KCFRodriguez2019101507.java:24)