在安卓/ java中,我试图用 +
替换某些字符串的空间,但它似乎并没有工作。我是不是做错了?
串串=Hello World的;
与string.replace(,+);
解决方案
字符串
对象是不可变的,所以替换
方法不会改变字符串,但创建一个新的,你必须重新保存:
串串=Hello World的;
串与string.replace =(,+);
In android/java, I'm trying to replace the space in some strings with a +
, but it doesn't seem to work. Am I doing it wrong?
String string="Hello world";
string.replace(" ", "+");
解决方案
String
objects are immutable, so the replace
method doesn't change the string but creates a new one that you have to re-save:
String string="Hello world";
string = string.replace(" ", "+");
上一篇:在使用的RelativeLayout用的LayoutParams DPRelativeLayout、LayoutParams、DP
下一篇:ListView控件不再调用setSelection后的onclick反应()控件、反应、ListView、onclick