title: NullPointerException in method
body: <p>I have a method that gets returns a type SENSOR 
  In the bold is where I am getting a runtime NullPointerException, cannot understand why.</p>
  
  <pre><code> public Sensor getSensorAt(int x,int y,GridMap grid)
        {
         /*go through sensor storage array 
         * for eachsensor index call the get x get y method for that 
         * compare it to the x,y of the robot 
         * 
         */  
  
          for(int i=0;i&lt;s1.length;i++){ 
               if(s1[i].getX() == x){    &lt;======= NullpointerException
              if(s1[i].getY()== y){ 
  
              return s1[i]; 
              } 
            }      
          } 
          return null;
        }
  </code></pre>