Q:
How to replace string with another string in java using String.replace() method?
belongs to collection: Java String Programs
Java String Programs
- Java program to read strings with different methods
- How to get length of the string in java?
- How to convert a character array to string in Java?
- How to calculate length of the string using String.length() method in Java?
- How to trim a given string using String.trim() method in Java?
- How to spilt string in substrings using String.split() in Java?
- Java program to demonstrate example of String.startsWith() and String.endsWith()?
- How to replace string with another string in java using String.replace() method?
- How to reverse a string in Java with and without using StringBuffer.reverse() method?
- How to check whether a given string is empty or not in Java?
- Java program to convert string to lowercase and uppercase
- Java program to get sub string from a given string
- Java program to convert any type of value to string value using String.valueOf() method
- Java program to compare two strings using String.compareTo() method
- Java program to input a string from user and reverse each word of given string
- Easiest way to check Given String is Palindrome String or not in Java
- Java program to get string and count number of words in provided string
- Java program to check given strings are Anagram or not
- Java program to Encrypt/Decrypt String Using AES 128 bits Encryption Algorithm
- Java program to separate all tokens (words) using StringTokenizer
- Java program to find occurrences of each character in a string
- Java program to reverse words of a string
- Java program to concatenate two strings
- Java program to get the last index of any given character in a string
- Java program to make first alphabet capital of each word in a string
- Java program to concatenate two strings without using library function
- Lowercase to uppercase conversion without using any library function in Java
- Uppercase to lowercase conversion without using any library function in Java
- Comparing Strings with equals() and compareTo() methods in Java
- String palindrome program in Java
- String comparison using Collator and String classes in Java
- String concatenation with primitive data type values in Java
- Java program to find occurrences of palindrome words in a string
- Java program to swap first and last character of each word in a string

Java programming
Consider the program:
Here, we have two strings str1 and str2, str2 will be replaced with str1 and finally, str1 is the replaced string (which will be returned through the function).
Output
need an explanation for this answer? contact us directly to get an explanation for this answer