title: Getting Java Lang Null pointer exception in Android
body: <p>I've been coding an android app and i've suddenly started getting an error, the error log says there is  Java.Lang.Null.pointer.exception on line 23 of my Game.java yet none of the code concerning that has been changed. Here is the code: Any ideas?</p>
  
  <p>Main class</p>
  
  <pre><code>public void onClick(View v) {
      switch (v.getId()) {        
      case R.id.about_button:
          Intent i = new Intent(this, About.class);
          startActivity(i);
          break;
      case R.id.ext_button:
          finish();
          break;
  
      case R.id.new_button:
  
          openNewGameDialog();
          break;
      }
  }
  
  private void openNewGameDialog() {
  
      new AlertDialog.Builder(this)
  
      .setTitle(R.string.diff_head)
  
      .setItems(R.array.difficulty,
  
       new DialogInterface.OnClickListener() {
  
          public void onClick(DialogInterface dialoginterface, 
                  int i) {
  
              startGame(i);
  
          }
      })
  
      .show();
  }
  
  
  private void startGame(int i) {
  
      Intent intent = new Intent(this, Game.class);
  
      intent.putExtra(Game.KEY_DIFFICULTY, i);
  
      startActivity(intent); 
  }
  </code></pre>
  
  <p>Game.java</p>
  
  <pre><code>public class Game extends Activity {
  
  public static final String KEY_DIFFICULTY = "w1279057.CW1.difficulty";
  public static final int DIFFICULTY_NOVICE = 0;
  public static final int DIFFICULTY_EASY = 1;
  public static final int DIFFICULTY_MEDIUM = 2;
  public static final int DIFFICULTY_GURU = 3;
  
  
  
  
              Random rand = new Random();
  
  
  line 23 &gt;&gt;  int diff = getIntent().getIntExtra(KEY_DIFFICULTY, DIFFICULTY_NOVICE);
  
  @Override   
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  </code></pre>