Why Dead Code Warning
I have dead code warning at this position: if('Email' == '+email.getText().toString()+'){ Toast.makeText(getApplicationContext(), 'email_id already available ', Toast.LENGTH_SHOR
Solution 1:
"Email" will never be equal to "+email.getText().toString()+". I think you wanted to use:
if ("Email".equals(email.getText().toString()))
Solution 2:
if("Email" == "+email.getText().toString()+")
"Email" can never be equal to "+email.getText().toString()+"
You probably wanted to write
if("Email" == email.getText().toString())
and you should use the equal-Method to compare Strings:
if("Email".equals(email.getText().toString()))
You'll find more informations about comparing Strings in Java HERE
Solution 3:
It should be
if("Email".equals(mail.getText().toString()))
{
Toast.makeText(getApplicationContext(), "email_id already available ", Toast.LENGTH_SHORT).show();
}
Solution 4:
Replace "Email" == "+email.getText().toString()+"
with "Email".equals(email.getText().toString())
Strings should always be compared using the equals()
method.'
Also, consider defining constants, e.g.
public static final String KEY_EMAIL = "Email"
then use
if(email.getText().toString().equals(KEY_EMAIL)) {...}
Solution 5:
you should use
if(email.getText().toString().equals("Email"){
Toast.makeText(getApplicationContext(), "email_id already available ", Toast.LENGTH_SHORT).show();
}
or use ignoreCaseEquals, explanation why it is dead code you must know by now by reading above answers
Post a Comment for "Why Dead Code Warning"