Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
これが私のコードです:
if(editText.getText().toString() == ""){ editTextBenefaction.setText("0"); }
なぜ彼は働かなかったのですか?
に変更します
if(editText.getText().toString().equals("")){
Java では.equals()、それらが同じ値を持っているかどうかを比較するために使用され、「==」はそれらが同じオブジェクトを参照しているかどうかを判断するために使用されます。
.equals()
さらに良い方法は、
if("".equals(editText.getText().toString())){
これは から保護するためNPEです。
NPE
Java 文字列ドキュメント