I wrote this statement in the main method 
the Exception will be in the (GuaranteeYears) so i put it in the try block.
First in the main I make a Store object and pass number 4 in parameter, in the Store class I will have a array called arrProduct that will have the length 4:
boolean flag1 = true;
while (flag1) {
    try {
        System.out.println("Ente GuaranteeYears");
        int GuaranteeYears=read.nextInt();
        StrongDevice s = new StrongDevice(code,type,price,Model,Capacity,GuaranteeYears); //the object
        flag1 = false;
        x.addProduct(s);
     }
and this is my add method
public boolean addProduct(Product p) {
    if(arrProduct.length==NumOfProduct)
        return false;
    arrProduct[NumOfProduct]=p;
    NumOfProduct++;
    return true;
}
My question is: when I make the object and add it to the array it gives me NullPointerException - why that happened? 
 
    