editText enter 1000 in the GetString field, pass it to GetString , when checking if(test.equals(params)) always turns out false . The screenshot shows that the test variable and params are equal to 1000. How to understand this? enter image description here

  public class MainActivity extends AppCompatActivity { EditText editText; Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onStart() { super.onStart(); button = (Button) findViewById(R.id.btn_start); editText = (EditText) findViewById(R.id.et_string); } public void onClick(View view) { GetString getString = new GetString(); getString.execute(editText.getText().toString()); } class GetString extends AsyncTask<String, Void, Void> { @Override protected Void doInBackground(String... params) { String test = "1000"; if (test.equals(params)) { Log.d("MyLog", "YES"); } else { Log.d("MyLog", "NO"); } return null; } } 

}

  • Is this the idea of ​​such a topic or some other editor? - Artem Konovalov
  • one
    Android Studio + plugin Material Design, the theme for highlighting the code itself made. - Yurii

1 answer 1

params is not a single String, but an array of Strings.

Use in comparison

 test.equals(params[0]) 

Read about varargs