Advertisements
Advertisements
प्रश्न
Describe the purpose of the following function with its syntax:
replace()
कोड लेखन
उत्तर
This function can be used to swap out every use of a character for another character or to swap out every occurrence of a String for another String.
Example:
String s = "By the people for the people";
s = s.replace("people", "teachers"); System.out.println(s);
Output: By the teachers for the teachers
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 4: String Handling - EXERCISES [पृष्ठ २८९]