关于Exception in thread "main" java.lang.NullPointerException错误求解
package fddffd;
class Customer
{
private int personcode,type,money;
Customer(){}
Customer(int t1,int t2,int t3)
{
personcode=t1;
type=t2;
money=t3;
}
public int getcode()
{
return personcode;
}
public int gettype()
{
return type;
}
public int getmoney()
{
return money;
}
}
class Queue
{
Customer p[];
int size=0;
Queue()
{
int i;
for(i=0;i<100;i++)
{
p[i]=new Customer();
}
}
public void add(Customer c)
{
p[size]=c;
size++;
}
public void delete()
{
int i;
for(i=0;i<size-1;i++)
{
p[i]=p[i+1];
size--;
}
p[i]=new Customer();
}
public Customer gettop()
{
return p[0];
}
public int getsize()
{
return size;
}
}
class Bank
{
public int amount,code=0,order=1,flag=0;
Queue q1,q2;
Bank(int n)
{
amount=n;
q1=new Queue();
q2=new Queue();
}
public void newcustomer(int t1,int t2)
{
code++;
Customer c1;
c1=new Customer(code,t1,t2);
q1.add(c1);
if(flag==0)
{
flag=dealq1();
}
else
{
dealq2();
flag=0;
}
}
public int dealq1()
{
if(q1.p[0].gettype()==1)
{
if(q1.p[0].getmoney()>amount)
{
Customer c2;
c2=q1.gettop();
q1.delete();
q2.add(c2);
return 0;
}
else
{
amount=amount-q1.p[0].getmoney();
display(q1);
order++;
q1.delete();
return 0;
}
}
else
{
amount=amount+q1.p[0].getmoney();
display(q1);
q1.delete();
return 1;
}
}
public void dealq2()
{
if(q2.p[0].getmoney()<amount)
{
Customer c2;
c2=q2.gettop();
q2.delete();
q2.add(c2);
}
else
{
amount=amount-q2.p[0].getmoney();
display(q2);
order++;
q2.delete();
}
}
public void display(Queue q)
{
System.out.println("我是第"+order+"个被处理的,我的个人信息为:编号为:"+q.p[0].getcode()+";业务类型为"+q.p[0].gettype()+";金额为:"+q.p[0].getmoney());
}
}
public class Test
{
public static void main(String[] args)
{
int i;
Bank b=new Bank(1000);
int test1[]={1,1,1,2,2};
int test2[]={700,500,200,300,400};
for(i=0;i<5;i++)
{
b.newcustomer(test1[i], test2[i]);
}
}
}
错误提示:Exception in thread "main" java.lang.NullPointerException
at fddffd.Queue.<init>(Test.java:35)
at fddffd.Bank.<init>(Test.java:69)
at fddffd.Test.main(Test.java:144)