
import java.util.*; public class employee { static int ch; static int emp[]; String name; int id,age; float sal; void insert() { employee[] emp=new employee[90];
Scanner r=new Scanner(System.in);
System.out.println("Enter the no of employees");
int n=r.nextInt();
for(int i=0;i<n;i++)
{
System.out.println("Enter details of employee"+(i+1));
emp[i].setdata();
}
System.out.println("---------------------details of employee-----------------------\n");
System.out.println("name \t id \t age \t salary");
for(int i=0;i<n;i++)
{
emp[i].getdata();
}
}
private void setdata() {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the name of employees");
name=sc.nextLine();
System.out.println("Enter the id of employees");
id=sc.nextInt();
System.out.println("Enter the id of employees");
age=sc.nextInt();
System.out.println("Enter the salary of employees");
sal=sc.nextFloat();
}
private void getdata() {
System.out.println(name+"\t"+id+"\t"+age+"\t"+sal);
}
void search()
{
System.out.println("searched");
}
void delete()
{
System.out.println("deleted");
}
void edit()
{
System.out.println("edited");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
employee e=new employee();
Scanner s=new Scanner(System.in);
System.out.println("Enter your Choice:");
System.out.println("1.Insert\n2.Search\n3.Delete\n4.Edit");
System.out.println("Enter your Choice:");
ch=s.nextInt();
switch(ch)
{
case 1:
e.insert();
break;
case 2:
e.search();
break;
case 3:
e.delete();
break;
case 4:
e.edit();
break;
case 5:
System.out.println("Wrong choice entered");
}
}
} Exception in thread "main" java.lang.NullPointerException at employee.insert(employee.java:19) at employee.main(employee.java:73) please sort it out
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.