The following code should replace the last occurrence of a ','
with a ')'
.
StringBuilder b = new StringBuilder(yourString);
b.replace(yourString.lastIndexOf(","), yourString.lastIndexOf(",") + 1, ")" );
yourString = b.toString();
Note This will throw Exceptions if the String
doesn't contain a ','
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…