Plzz solve my error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
22nd Jul 2021, 8:36 AM
Kajal Kumari
2 Answers
+ 5
Or else Use string class instead of string buffer, if you may trying this way: public class Program { public static void main(String[] args) { String sb=new String("hello"); System.out.println(sb.replace('h','r')); System.out.println(sb); // original string won't change.. try to check } }
22nd Jul 2021, 9:50 AM
Jayakrishna 🇮🇳
+ 3
Kajal Kumari replace method have 3 parameters 1 - start index int type 2 - end index int type 3 - a string not character System.out.println(sb.replace(0, 1, "r"));
22nd Jul 2021, 8:46 AM
A͢J
A͢J - avatar