Witam. Chciałbym zamienić ostatni znak ('+') w stringu na inny('='). Niestety zamienia mi wszystkie + na =.
Część kodu, która dotyczy problemu:
l= a.lastIndexOf('+');
if (a.endsWith(q))
{a=a.replace(a.charAt(l), '=');};
Witam. Chciałbym zamienić ostatni znak ('+') w stringu na inny('='). Niestety zamienia mi wszystkie + na =.
Część kodu, która dotyczy problemu:
l= a.lastIndexOf('+');
if (a.endsWith(q))
{a=a.replace(a.charAt(l), '=');};
coś takiego ?
String napis = "bleeeble+";
String newString = "";
if (napis.charAt(napis.length() - 1) == '+') {
newString = napis.substring(0,napis.length() - 1)+"=";
}
System.out.println(newString);
No nie dziwne, że wszystko zamienia :>
http://download.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#replace%28char,%20char%29
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
[...]