I am my making a project Bank management System. The code here is of the 3rd page of my project where user have to choose the account type he wants. If he is not selecting any account type then a message dialog will pop up which shows account type is required. But I am not getting message dialog box. here is the piece of code where I think the problem isn bt I am unable to resolve it.
'''JAVA
public void actionPerformed(ActionEvent ae)
{
String accountType=null;
if(ae.getSource()==submit)
{
if(r1.isSelected()) {
accountType="Saving Account";
} else if(r2.isSelected())
{
accountType="Fixed Deposit Account";
}
else if(r3.isSelected())
{
accountType="Current Account";
}
else if(r4.isSelected())
{
accountType="Recuuring Deposit Account";
}
Random random=new Random();
String cardnumber=" "+Math.abs((random.nextLong()%90000000L+1609972900000000L));
String pinnumber=" "+Math.abs((random.nextLong()%9000L+1000L));
String facility="";
if(c1.isSelected())
{
facility=facility+" ATM Card";
}
else if(c2.isSelected())
{
facility=facility+" Internet Banking";
}
else if(c3.isSelected())
{
facility=facility+" Mobile Banking";
}
else if(c4.isSelected())
{
facility=facility+" Email & SMS Alerts";
}
else if(c5.isSelected())
{
facility=facility+" Cheque Book";
}
else if(c6.isSelected())
{
facility=facility+" E-Statement";
}
try {
if(accountType.equals("")){
Conn conn=new Conn();
String query1="insert into Signupthree values('"+formno+"','"+accountType+"','"+cardnumber+"','"+pinnumber+"','"+facility+"')";
String query2="insert into login values('"+formno+"','"+cardnumber+"','"+pinnumber+"')";
conn.s.executeUpdate(query1);
conn.s.executeUpdate(query2);
JOptionPane.showMessageDialog(null, "Card Number: "+cardnumber+"\n Pin: "+pinnumber);
}
else{
JOptionPane.showMessageDialog(null, "AccountType is Required");
}
} catch (Exception e) {
System.out.println(e);
'''
I am getting this error '''java java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "accountType" is null`