About 46,700,000 results
Open links in new tab
  1. String replace() method in Java with Examples - GeeksforGeeks

    Feb 16, 2024 · The following examples demonstrate how to use the replace () method in Java: To show the working of replace (char old, char new). We can implement the replace () method with substring/CharSequence just like with char. To show the working of the replace (String target, String replacement) method.

  2. 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.

  3. How to replace ' \' with '/' in a Java string? - Stack Overflow

    Apr 18, 2013 · It works if you use replace() with no regular expressions: If throwed me an StringIndexOutOfBoundsException exception under Windows XP (in Spanish locale). Still don't know why. If it is a file path, you should try "File.separator" instead of '\' (in case your application works with Nix platform)

  4. replace String with another in java - Stack Overflow

    You can use replace method to achieve this: String outputString1 = inputString.replace("HelloBrother", "Brother"); String outputString2 = inputString.replace("JAVAISBEST", "BEST");

  5. How do I replace a character in a string in Java ... - Stack Overflow

    First, Strings are immutable objects. Second, I want to replace a character (&) with several characters (amp&;). How should I approach this? if(ch == '&') { Try using String.replace() or String.replaceAll() instead. (Both replace all occurrences; replaceAll allows use of regex.)

  6. Remove or Replace Part of a String in Java - Baeldung

    Jun 15, 2024 · In this tutorial, we’re going to be looking at various means we can remove or replace part of a String in Java. We’ll explore removing and/or replacing a substring using a String API, then using a StringBuilder API and finally using …

  7. Java String replace() - Programiz

    In this tutorial, you will learn to use the Java String replace () method with the help of examples.

  8. Java String replace () method - Tpoint Tech

    Mar 24, 2025 · The Java String class replace() method returns a string replacing all the old char or CharSequence to new char or CharSequence. Since JDK 1.5, a new replace() method is introduced that allows us to replace a sequence of char values.

  9. 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.

  10. 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.

Refresh