title: Trying to find factorial and display it in a new activity. Crash on startup
body: <p>I'm trying to make this app where I'm taking a value from the main activity sending it to the second one where I generate it's factorial and display it. I'm probably doing something wrong, here is the code of the mainactivity class:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements 
  View.OnClickListener
  {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
  EditText n = (EditText) findViewById(R.id.input_num);
  Bundle bundle = new Bundle();
  
  public void onClick(View v)
  {
      switch (v.getId())
      {
          case R.id.ok_button:
              int val = Integer.parseInt(n.getText().toString());
              bundle.putInt("nval",val);
              Intent intent = new Intent(this, Answer.class);
              intent.putExtras(bundle);
              startActivity(intent);
              break;
  
      }
  }
  }
  </code></pre>
  
  <p>This is the second class:</p>
  
  <pre><code>public class Answer extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_answer);
      Intent intent = getIntent();
      Bundle bundle = intent.getExtras();
      TextView textView = (TextView) findViewById(R.id.answer);
      int val = bundle.getInt("nval");
      int x = 1;
      for(int i=1; i&lt;val; i++)
      {
          x =(x*i);
      }
  
      String txt = Integer.toString(x);
      textView.setText(txt);
  }
  </code></pre>
  
  <p>XML for main activity:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  tools:context="com.manan.fibbo.MainActivity"&gt;
  
  &lt;EditText
      android:id="@+id/input_num"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginStart="100dp"
      android:layout_marginEnd="120dp"
      android:layout_marginTop="180dp"
      android:hint="@string/fibnum"
      /&gt;
  &lt;Button
      android:id="@+id/ok_button"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginStart="100dp"
      android:layout_marginTop="20dp"
      android:layout_marginEnd="120dp"
      android:text="@string/but_txt"
      /&gt;
  </code></pre>
  
  <p></p>
  
  <p>XML for second activity:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.manan.fibbo.Answer"&gt;
  
  &lt;TextView
      android:id="@+id/answer"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      tools:layout_editor_absoluteY="0dp"
      tools:layout_editor_absoluteX="8dp" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>I'm probably doing a million things the wrong way here, this is just a mockup/test code. Please excuse my shitty programming practices.</p>
  
  <p>Here is the thing I got from debug:</p>
  
  <p><a href="https://pastebin.com/19QtVLZD" rel="nofollow noreferrer">https://pastebin.com/19QtVLZD</a></p>