we can replace it by doin like this:
StringBuffer str = new StringBuffer("this is string");
str.replace(5, 7, "was");
and then print it