About 263,000 results
Open links in new tab
  1. Java String replace() Method - W3Schools

    Return a new string where all "l" characters are replaced with "p" characters: Try it Yourself » The replace() method searches a string for a specified character, and returns a new string where the specified character (s) are replaced.

  2. String replace() method in Java with Examples - GeeksforGeeks

    Feb 16, 2024 · The following examples demonstrate how to use the replace() method in Java: Example 1: Java String replace(char old, char new) Method To show the working of replace(char old, char new).

  3. Java String replace() - Programiz

    replace() Syntax. The syntax of the replace() method is either. string.replace(char oldChar, char newChar) or. string.replace(CharSequence oldText, CharSequence newText) Here, string is an object of the String class.

  4. Java String replace() : Replace All Occurrences in Text

    Oct 11, 2023 · Java String replace () searches for a literal substring and replaces each occurrence with the replacement string beginning with index 0.

  5. Java String replace() example - Java Guides

    In this guide, you will learn about the String replace () method in Java programming and how to use it with an example. 1. String replace () Method Overview. The replace () method of Java's String class is utilized to replace all the occurrences of a specified character or substring with another character or substring within the invoking string.

  6. Java String Replace(), ReplaceAll() & ReplaceFirst() Methods

    Apr 1, 2025 · As the name itself suggests, the replace () method is used to replace all the occurrences of a specific character of a String with a new character. The Java String Replace has two variants as shown below. #1) The replace method for the character. The syntax for character replace: #2) The replace method for the character sequence.

  7. String replace method - Java Code Geeks

    Nov 11, 2012 · In short, to replace a String you should: Create a new String. Use replace(char oldChar, char newChar) API method. This method returns a new string resulting from replacing all occurrences of oldChar in this string with newChar. Use replaceFirst(String regex, String replacement) API method.

  8. Java String replace() Method Examples - Scaler

    Apr 25, 2022 · To replace all occurrences of a particular character with another character in Java, we use the first syntax of the replace () method in Java. oldChar - The character to be replaced in the string. newChar - The character to be used instead of oldChar in the string.

  9. Java String replace() Method Examples

    Jul 22, 2019 · Java String replace() method is used to replace part of the string and create a new string object. Since the string is immutable, the original string remains the same. The replace() method returns a new string and we have to assign it to a variable to use it.

  10. Java String Replace Method - Online Tutorials Library

    Learn how to use the Java String replace method to replace characters or substrings in a string with clear examples and explanations.

  11. Some results have been removed
Refresh