i need help urgently. i try to add new array element into my array which is cusName[20]. the process is that if the name already exist it wont add otherwise it will add to array cusName[20]. however i got error message java.lang.NullPointerException null. Please help me with the following code
import java.util.*;
public class AddCustomer
{
private String[] cusName;
private int index;
public AddCustomer()
{
index = 5;
cusName = new String [20];
cusName[0]= "Allen";
cusName[1]= "Lisa";
cusName[2]= "Jessica";
cusName[3]= "Nicole";
cusName[4]= "Ken";
}
public void addCustomer()
{
Scanner in = new Scanner (System.in);
System.out.println("Input Customer Name");
String name=in.next();
int k, place, index;
place= -1;
for (k=0; k<cusName.length; k++)
{
if (cusName[k].equalsIgnoreCase(name))
{
System.out.println("Sorrry customer name " + name +" already exists");
}
}
if (place == -1)
{
for (index=0; index<cusName.length; index++)
{
cusName[index]=name;
}
//System.out.println(cusName[index]);
}
}
}