English

Describe the purpose of the following function with its syntax: replace() - Computer Applications

Advertisements
Advertisements

Question

Describe the purpose of the following function with its syntax:

replace()

Code Writing

Solution

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
  Is there an error in this question or solution?
Chapter 4: String Handling - EXERCISES [Page 289]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 4 String Handling
EXERCISES | Q VIII. 5. | Page 289
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×