i am getting null pointer exception at runtime what should be done my program is given below...it is all about library mangement
/*when ever i am trying to search for the book after accessing the number of the book it is giving me null pointer exception and even in display and return also it is giving me null pointer exception*/
Code:package pack3;
import pack1.*;
import pack2.*;
import java.util.*;
public class user extends pack2.admin
{
Scanner s=new Scanner(System.in);
public int i,choice;
admin a=new admin();
//book b[]=new b();
public void staff()
{
System.out.println("1.Search\n2.Lending\n3.Returning\n4.Display");
System.out.println("Enter the choice:");
choice=Integer.parseInt(s.nextLine());
switch(choice)
{
case 1:
a.search();
break;
case 2:
System.out.println("Enter the number of books you want to lend:");
int le=Integer.parseInt(s.nextLine());int m=5;
for(int i=0;i<le;i++)
a.lending(i,m);
break;
case 3:
a.returning();
break;
case 4:
System.out.println("Enter the access number of the book:");
i=0;
while(b[i].acc!=acc1)
b[i] = new book();
i=i+1;
if(i<bookno)
System.out.println("The details of the book is:");
b[i].display();
break;
default:
System.out.println("wrong choice");
}
}
public void student()
{
System.out.println("1.Search\n2.Lending\n3.Returning\n4.Display");
System.out.println("Enter the choice:");
choice=Integer.parseInt(s.nextLine());
switch(choice)
{
case 1:
a.search();
break;
case 2:
System.out.println("Enter the number of books you want to lend:");
int le=Integer.parseInt(s.nextLine());int m=3;
for(int i=0;i<le;i++)
a.lending(i,m);
break;
case 3:
System.out.println("Enter the numebr of books you want to return:");
int re=Integer.parseInt(s.nextLine());
for(int i=0;i<re;i++)
a.returning();
break;
case 4:
System.out.println("Enter the access number of the book:");
i=0;
while(b[i].acc!=acc1)
b[i] = new book();
i=i+1;
if(i<bookno)
System.out.println("The deatails of the book is:");
b[i].display();
break;
default:
System.out.println("wrong choice");
}
}
}
