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.
android / javaで、一部の文字列のスペースを。に置き換えようとしています+が、機能しないようです。私はそれを間違っていますか?
+
String string="Hello world"; string.replace(" ", "+");
Stringオブジェクトは不変であるため、replaceメソッドは文字列を変更しませんが、再保存する必要がある新しい文字列を作成します。
String
replace
String string="Hello world"; string = string.replace(" ", "+");
Javaでは、StringBufferクラスは可変文字列を提供します。replaceメソッドは同じオブジェクトを返します。