I am making a program that solves an equation.
I have a variable that changes: i, and a string that is entered: parseLine
What is the easiest way to make:
parseLine = "100 + x"
when i = 1;
into:
"100 + 1"
I tried
String ir = Double.toString(i);
parseLine.replace("x", ir);
but the output is still 100 + x
a
Stringin java is immutable – you can’t change it. Thereplacemethod returns a newStringinstance: