title: Need help outputting "You must enter a name" when nameText is null. With the code I currently have it doesn't recognize when the nameText is empty
body: <p>MainActivity</p>
  <pre><code>package com.example.greetings_john_sporn;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class MainActivity extends AppCompatActivity {
  
  EditText nameText;
  TextView textView;
  Button btn;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      nameText = (EditText) findViewById(R.id.nameText);
      textView = (TextView) findViewById(R.id.textGreeting);
      btn = (Button) findViewById(R.id.buttonSayHello);
      nameText.setText(&quot;&quot;);
  }
  
  public void sayHello(View view) {
  
      if(nameText != null) {
          textView.setText(&quot;Hello &quot; + nameText.getText());
          btn.setEnabled(true);
      } else {
          textView.setText(&quot;You must enter a name&quot;);
          btn.setEnabled(false);
      }
  
  }
  }
  </code></pre>
  <p>Need help setting the text to &quot;You must enter a name&quot; when the <code>nameText</code> is null. For some reason even when the <code>nameText</code> field is empty it still outputs &quot;Hello&quot; when it should be outputting &quot;You must enter a name&quot;.</p>