AndroidStudio VM shutdown myapp becaouse of setText method

Gregon20 :
    public void save(View view)
    {
        if (!editText.getText().toString().matches(""))
        {
            int userAge = Integer.parseInt(editText.getText().toString());
            textView.setText(""+userAge);
        }
    }

this code work with VM but if i change part of

textView.setText(""+userAge);

this to this

textView.setText(userAge);

onclick method shutdown app on VM both code work same goal, but i don't understand why second row doesn't work

moxy :

You can't use setText with integer inside. You first need to convert it to a string. There is two options, textView.setText(""+userAge);, textView.setText(String.valueOf(userAge));

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=366991&siteId=1