String sequence can be replaced with other string literal the help of replace() method in java. replace() method returns a value in String. Replace method replace string character with first occurrence in string sequence. Use of String replace() in java is shown below.
Example of String replace() in java, JSP
public class StringRemoveExample { public static void main(String[] args) { String string = "Find String and replace"; String newString = string.replace("Find", "New"); System.out.println("Replaced String :"+newString); } }
Output
Replaced String :New String and replace
Tags: String



Link to Us