我有一个字符串:
String fieldName = "A=2,B=3 and C=3,";
现在我想,
用空格替换最后一个。
我用过:
if (fieldName.endsWith(",")) {
fieldName.replace(",", " ");
fieldName = fieldName.replace((char) (fieldName.length() - 1), 'r');
}
System.out.println("fieldName = " + fieldName);
但我仍然得到相同的旧字符串。我怎样才能得到这个输出呢?
fieldName = A=2,B=3 and C=3