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 [पृष्ठ २८९]