Hi, I'm trying to insert a search function into my program. I used 2 classes
class PatientInfo{
private void BAddActionPerformed(java.awt.event.ActionEvent evt) {
PatientAddress pInfo = new PatientAddress();
lName = txtLastName.getText();
pInfo.getLName(lName);
txtLastName.setEditable(false);
}
private void BSearchActionPerformed(java.awt.event.ActionEvent evt) {
PatientAddress pInfo = new PatientAddress();
lName = txtSearchName.getText();
pInfo.searchInfo(lName);
txtLastName.setText(pInfo.lastName);
}
}
public class PatientAddress extends PatientInfo{
public int ctr, loc;
public String lastName;
public String[] lNameArr = new String[50];
public void getLName(String lName){
for(ctr=0; ctr<lNameArr.length;ctr++)
{
lNameArr[ctr] = lName;
}
}
public void searchInfo(String lName){
loc = -1;
for(ctr=0;ctr<lNameArr.length;ctr++)
if(lNameArr[ctr].equalsIgnoreCase(lName))
{
loc=ctr;
break;
}
if(loc>=0){
lNameArr[ctr] = lastName;
}
}
the thing is whenever I click the search button, I get this error. can anyone tell me what's this error means?
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at hospitalbilling.PatientAddress.searchInfo(PatientAddress.java:32)