Java String.replace not working even after assigning to a variable.
I have a JSON formatted string like as follows.
{"Obligations":["\nAggregate","\nDelay"],"Result":"Permit"}
I want to remove the \n from the string.
I used the following piece of code. There is no difference.
String test =jsonObject.toString().replace("\n", "");
System.err.println(test);
But I get the same result. Is there something wrong in it ?