title: Error:java.lang.IllegalStateException: Could not execute method of the activity
body: <p>Sorry i am new in android</p>
  
  <p>I have 2 <strong>EditTexts</strong> and 1 <strong>button</strong> i am going to when i push the button the value of EditTexts be printed, but i give the error</p>
  
  <p>The XML:</p>
  
  <pre><code>    &lt;Button
          android:id="@+id/submit"
          android:layout_width="212dp"
          android:layout_height="wrap_content"
          android:layout_x="52dp"
          android:layout_y="337dp"
          android:text="@string/Submit"
          android:onClick="submit" /&gt;
  
      &lt;EditText
          android:id="@+id/quantity"
          android:layout_width="182dp"
          android:layout_height="wrap_content"
          android:layout_x="9dp"
          android:layout_y="86dp"
          android:ems="10" /&gt;
  
      &lt;EditText
          android:id="@+id/Unit"
          android:layout_width="182dp"
          android:layout_height="wrap_content"
          android:layout_x="11dp"
          android:layout_y="15dp"
          android:ems="10" &gt;
  
          &lt;requestFocus /&gt;
     &lt;/EditText&gt;
  </code></pre>
  
  <p>The Java class is:</p>
  
  <pre><code>    public class add extends Activity
      {
  
          private static  String[] montharray; 
  
          Button   mButton;
  
          EditText Unit;
          EditText quantity;
  
          private int days;
  
          @Override
          public void onCreate(Bundle savedInstanceState) 
          {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.add);
  
              Unit          =(EditText) findViewById(R.id.unit);
              quantity      =(EditText) findViewById(R.id.quantity);
              mButton       =(Button) findViewById(R.id.submit);
          }  
  
  
  
          public void submit(View view) 
          {
  
  
              System.out.println("Unit=    "+Unit.getText().toString()+"   quantity=   "+quantity.getText().toString());  
  
  
          }
  }
  </code></pre>
  
  <p>Here is thr errors:</p>
  
  <pre><code>05-16 15:37:35.857: E/AndroidRuntime(17951): FATAL EXCEPTION: main
  05-16 15:37:35.857: E/AndroidRuntime(17951): java.lang.IllegalStateException: Could not execute method of the activity
  ...
  
  
  05-16 15:37:35.857: E/AndroidRuntime(17951): Caused by: java.lang.NullPointerException
  05-16 15:37:35.857: E/AndroidRuntime(17951): at net.learn2develop.UsingIntent.add.submit(add.java:56)
  </code></pre>
  
  <p>I initiate all the objects, what is the  <strong>java.lang.NullPointerException</strong>?</p>