I got a string test "{\"userName\": \"<userName>\",\"firstName\": \"<firstName>\",\"lastName\": \"<lastName>\"}". what I want is that I want to replace things in angular brackets with dynamic values. Sample code:
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
String toBeReplaced0 = "alpha";
String toBeReplaced1 = "beta";
String toBeReplaced2 = "gama";
String test = "{\"userName\": \"<userName>\",\"firstName\": \"<firstName>\",\"lastName\": \"<lastName>\"}";
}
}
Now in this code I want to replace <userName> with alpha, <firstName> with beta, <lastName> with gama at once without making multiple string objects. This is not a homework question. test string can have more angular elements in it to be filled with dynamic values. How can I do this with replace method or any thing else..