title: How do I compare password and confirm password?
body: <p>I am getting error in</p>
  
  <pre><code>final EditText etregpassword = (EditText)findViewById(R.id.etregpassword);
  </code></pre>
  
  <p>I would like help with the comparison of password and confirm password and to display the error in password mismatch.</p>
  
  <pre><code>public class RegisterActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_register);
  
      final EditText etregname = (EditText)findViewById(R.id.etregname);
      final EditText etregemailid = (EditText)findViewById(R.id.etregemailid);
      final EditText etregpassword = (EditText)findViewById(R.id.etregpassword);
      final EditText etconfirmregpassword = (EditText)findViewById(R.id.etconfirmregpassword);
      final Button regbutton = (Button) findViewById(R.id.regbutton);
  
      regbutton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              final String User_name = etregname.getText().toString();
              final String Email_id = etregemailid.getText().toString();
              final String Password = etregpassword.getText().toString();
              final String Confirm_password = etconfirmregpassword.getText().toString();
  
              Response.Listener&lt;String&gt; responseListner = new Response.Listener&lt;String&gt;(){
  
                  @Override
                  public void onResponse(String response) {
                      try {
                          JSONObject jsonObject = new JSONObject(response);
                          boolean SUCCESS = jsonObject.getBoolean("success");
  
                          if(SUCCESS){
                              Intent intent = new Intent(RegisterActivity.this,LoginActivity.class);
                              RegisterActivity.this.startActivity(intent);
                          }
  
                          else{
                              AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
                              builder.setMessage("Register Failed")
                                  .setNegativeButton("Retry",null)
                                      .create()
                                       .show();
  
                          }
  
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
  
                  }
              };
  
              RegisterRequest registerRequest = new RegisterRequest(User_name,Email_id,Password,Confirm_password,responseListner);
              RequestQueue queue= Volley.newRequestQueue(RegisterActivity.this);
              queue.add(registerRequest);
          }
  
      });
  
  
  }
  
  }
  </code></pre>