title: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)
body: <p>I'm getting a error when I hit my start button for my timer. I don't know why its not working. I had it working with this code before but now when I try and run it it just immediately crashes with the error. </p>
  
  <p>Here is the class for my timer code:</p>
  
  <pre><code>package com.example.pc.mealtimers;
  
  import android.os.Bundle;
  import android.os.CountDownTimer;
  import android.support.v7.app.AppCompatActivity;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class WegmansActivity extends AppCompatActivity{
      static TextView wegmansTimerText;
      static Boolean counterIsActive = false;
      Button wegStart;
      static CountDownTimer countDownTimer;
  
  
  
  
      public static void resetTimer(){
          wegmansTimerText.setText("16:00");
          countDownTimer.cancel();
          counterIsActive = false;
  
      }
  
      public static void wegmansTimerInit() {
          if (counterIsActive == false) {
              counterIsActive = true;
              //wegButton.setText("Stop!");
              countDownTimer = new CountDownTimer(960000, 1000) {
  
                  @Override
                  public void onTick(long millisUntilFinished) {
                      updateTimer((int) millisUntilFinished / 1000);
                  }
  
                  @Override
                  public void onFinish() {
                     wegmansTimerText.setText("0:00");
                  }
              }.start();
          }else{
              wegmansTimerText.setText("16:00");
              resetTimer();
  
          }
  
      }
  
      public static void updateTimer(int secondsLeft){
  
          //System.out.println("TICKING");
          counterIsActive = true;
          int minutes = (int) secondsLeft / 60;
          int seconds = secondsLeft - minutes *60;
          String secondString = Integer.toString(seconds);
          if (seconds &lt;=9){
              secondString = "0" + secondString;
  
          }
          wegmansTimerText.setText(Integer.toString(minutes) + ":" + secondString);
  
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_wegmans);
  
          wegmansTimerText = (TextView)findViewById(R.id.wegmansTimerText);
          wegStart = (Button)findViewById(R.id.startButton);
      }
  }
  </code></pre>
  
  <p>Here is my code for the layout in which the timer is located:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".WegmansActivity"&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Back"
          android:id="@+id/backButton"
          android:layout_alignParentTop="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:onClick="backButton" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="400°"
          android:id="@+id/degreeText"
          android:textSize="60sp"
          android:layout_below="@+id/backButton"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="40dp" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="16:00"
          android:id="@+id/wegmansTimerText"
          android:layout_centerVertical="true"
          android:layout_centerHorizontal="true"
          android:textSize="60sp" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Start"
          android:id="@+id/startButton"
          android:layout_marginBottom="52dp"
          android:textSize="20sp"
          android:padding="20dp"
          android:onClick="wegmansTimer"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>My error::</p>
  
  <pre><code>java.lang.IllegalArgumentException: Binary XML file line #44: Process: com.example.pc.mealtimers, PID: 2346
  java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
      at com.example.pc.mealtimers.WegmansActivity.updateTimer(WegmansActivity.java:60)
      at com.example.pc.mealtimers.WegmansActivity$1.onTick(WegmansActivity.java:33)
      at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:133)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>