[Solved] Replace String variable with exact string

[ad_1]

If I understand your question, you could use String.replace(CharSequence, CharSequence) like

String str="abcd";
String rep="cd";
String nv = "kj";
str = str.replace(rep, nv); // <-- old, new
System.out.println(str);

Output is (the requested)

abkj

1

[ad_2]

solved Replace String variable with exact string