how to replace a character with another character in a string in java

Solutions on MaxInterview for how to replace a character with another character in a string in java by the best coders in the world

showing results for - "how to replace a character with another character in a string in java"
Cecilia
02 Aug 2018
1//short answer: you cannot individually change any specific character
2//of a String in java. You can however do this:
3
4String s1 = "This is a String";
5String s2 = s1.substring(0, 8) + "o" + s1.substring(9);
6System.out.println(s2);
7//Prints "This is o String", replaced the 8th character with an o
Hugh
14 May 2018
1String str = ".............................."; 
2
3        int index = 5; 
4  
5        char ch = '|'; 
6 
7        StringBuilder string = new StringBuilder(str); 
8        string.setCharAt(index, ch); 
9
10        System.out.println(string); 
Adèle
04 Oct 2017
1public class JavaExample{
2   public static void main(String args[]){
3	String str = new String("Site is BeginnersBook.com");
4
5	System.out.print("String after replacing com with net :" );
6	System.out.println(str.replaceFirst("com", "net"));
7
8	System.out.print("String after replacing Site name:" );
9	System.out.println(str.replaceFirst("Beginners(.*)", "XYZ.com"));
10   }
11}
queries leading to this page
how to change a character at an index in javareplace megthod in javachange a character in a string javareplace a char from a string javareplace character in stringreplace a letter in string javareplace all characters in a string javastring replace javhow to change a character of a string javareplace character in string with string in javachanging characters in a string javahow to rewrite a string in javareplace fun in javahow to alter a character of a string in javareplace method injacajava modify character in a stringchange one char string javareplace function javajava string replace character at indexjava string change characterstring modify a certain caracter javamodify characters in string javahow to change a string javareplace string javastringreplacement in java stringreplace in string in jva astring replace in javareplace at index in string javareplace character in string programhow to modify a string in place in javareplace string from index javareplace character in string java at indexhow to replace 5c char in string javahow can we replace character in java stringsjava how replace 27java replace charsequencehow to do string replace by indexreplace certain ccharector with another javareplace a character at a specific index in a char arrayreplace char in string java mrthod 5cjava replace char in stringreplacing a character inside a string java replacing with 2f in javahow to change an character in a string in javamove characters in string javahow to change a character in a string in javastr replace javareplace one character in a string javahow to replace a particular character in a string in javadeleting characters from a string and adding it to a new one javahow to replace some character in string in javajava replace stringreplace substring in javareplace values in string in javareplace string in javareplace a char of a string with another charjava replacing characters in a stringreplace a string in javareplace a character from string in javareplace caharcter in string 5chow to change single character of a string in javareplace in java for stringjava how to change a character of a stringjava how to change a character in stringreplace a word in a character string javareplace letter in strning javahow to replace a char in a string in javareplace method javastring replace methodreplace string with another string javajava replace characters in a string with another stringjava string replace cahracterhow to change the char in string javajava replace string character at indexjava string replace at charjava change char in stringchar replacement in javareplace value in string 27 27 replacing with 2f in javatext replace 28 22 22 2c 22 2b 22 29 in javahow to replace a int character in a string in javahow to read character of strings and replace it in javareplace a char in javastring replace letter javareplace a string in another stringjava string replace at indexreplace a character at particular index in javajava replace string with charhow to change one string character javareplace character in strijng javahow to change one letter in a string javajava string substitute stringjava how to replace characters in a stringhoe to change a particular character of a stringreplace the characters in a string in javachanging a character in a string javajava string replace exampleshow to replace characetrs with others in javareplace charecter into stringreplace in stringsjava replace up to certain characters from stringreplace java stringreplace only single character in string javahow to change the text in a string javareplace char in a string method in javahow to change char in a string javahow to replace character at particular index in javahwo to replace a single character out of a string in javachange character of string javareplace character in javajava replace charsubstitute string javajava replace charactershow to replace a character at an index in a string in javajava string replace 5creplace char in string javareplace character in a string javareplace in javareplace a char in stringhow to replace a character in a certain index in a string in javareplace in a string javareplace function in javamodify character in string javastring replace functions in javareplace letters in a string javareplace character in string java from any charater in other stringhow to use replace method in javahow to change a value at an index in string javahow to get the replcce charecter of a string in javccajava replace 26 by c2 a7java replace character in a stringreplace function in java stringreplace string characterhow to use replace functionin javachange a character in a string in javareplace letter javareplace the character in a string in javareplace with in javareplace function jaasubstitute a character in string javahow to move a character in a string javahow to replace a string with another string inside a string in javajava replace the 22 5c 22 in a stringchange character string javahow to change the string methodhow to replace a chacter in stringstring replace java string to charprogram to replace some character in string javareplace chracter at indexreplace string with indexhow to replace strings in javasjava string replacejava find and replace using indexofreplace 5b character in java stringreplacing in string javareplace chat in stringreplace java charhow to replace char with string javareplace the heating element in string in javahow to chacng char in stringreplace 2f with 5c in javahow to change a char in string javareplace string value with others javahow to vhange letter in javahow to replace a character in a string using javareplace string java withreplace symbol in string javareplace a character at a specific index in a string in javahow to repace strings replace a given substring in javajava replace 22 charreplace char in char list javareplace 5c 22 with 22 in strings javareplace a character in array javajava replace 2c by in stringreplace char javajava replace string with another stringeasy way to replace a part of a string with a char in javajava replace string in stringhow to replace some part in string in javareplace a particular character in a string javastring change characters javastring replace method in javajava string replace charreplacing a character in a string in javareplace character in java stringchange char in a string javahow to replace the character in string in javajava replace a single char in a stringreplace char in a string with indexeshow to set the value of a char at an index in a string javahow to repalce certain symbols in a string javahow to replace a character in a string in javajava change character in stringchange a char in string javahow to replace 27 5c 27in stringreplace character in string in javahow to replace a char in javaput particular character in string javareplace 28 22 2f 22 2c 22 22 29 character in string javareplace a char in a word javareplace index of string javahow to use replace in java for stringreplace certain ccharector with another java in stringhow to replace characters in a string javahow to change string in javafind an element and replace it with another string using javajava how to replace char in stringreplace character index javareplace method in strings in javachange character in string javareplacing certain character from a string javareplace a character in a string in javareplace a char with a stringhow to replace character in stringhow to change the value of a string in javajava replace c3 b2 with ostring replace letter at indexhow to change the data inside a string javareplace single character in string java 40 replace javareplace method string javareplace things in strings java replace 28 29 javareplace char in stringhow to use replace 28 29 in javahow to use replace function in javahow to set a character in a string with another character javareplace specific character in string javahow to replace a charater in javareplace 2a from string javareplace characters in javajava replace 5c in stringprogram to replace a substring in a string in javajava string substitutionhow replace char in stringreplacing a character in string via substringchange string in another method in javajava writing replace methodreplace 22 with 27 in javajava replace 7b 7dreplace text character javajava code to replace a character in stringhow to change character in string javareplace character with in java stringjava replace all character from texthow to replace character in string in javajava replace 7b 7d string replace character at an index in string javareplace single char in string javahow to replace a character in a string in java with indexhow to change a specific character in a string javareplacement character javahwo to change cahracter in text in javareplace char with other javahow to replace the 2a char in string replace all javareplace 22 22 javareplace a character from a string javahow to replace a substring with a char javacharat java changereplace char in stirng injvareplace characters ins tringfind and replace in a string javajava string replace 3freplce character in string javahow to replace 2a in javajava change 1 character in stringjava replace char with stringreplace at index a char in string javajava stringbuilder replace characterreplace chars in javahwo to edit char in tring javareplace liketstring javachange character of index in javachange character in a string in javajava replace only one character in a stringstr replace javajava replace characters in stringchange specific character from string javahow to rplace a charecter in string in javareplace character at ith index in string javajava string change character at positionjava program to replace occurrences of specific char in a stringreplace all of a certain ccharector with another java in stringhow to change character in a string in javajava program to replace each character in a string with it 27s next letterchar in a string replace with index in javareplace string jacadifferent ways to change string in javahow to update a character value in stringchange individual string character javahow to replace words in a string javajava string replacereplace a character with other character in stringreplace a letter in a string javajava replace letter in stringhow to replace a character in a string javareplace character in string javareplacing characters in strings with replace 28 29 in javahow to change string characters javahow to modify a char in string javareplace a character in string javareplace character with 40 in javacharacter substitutions javareplace any charcter in string javajava replace a word in stringreplacing things in strings javastring replace character javastring replace java questionsstring character replace javabuild a ne string replcing charcters javahow to change a char of a string in javahow to replace a letter in a string javareplace a given character to a string in javajava set char at stringhow to replace specific character from string in javareplace index in string javareplace values in string javareplace char of a stringhow to replace 2f in javahow to replace an index in a string javajava code to replace characters in a stringreplace characters from the stringsjava replace 1 char in stringstring replace method javachange character of a string in javajava string replace at posreplace character with 2f character in javahow to replace text in javaedit a stringhow to replace a word in a string in java using replace methodhow to modify strings javajava string replace replacestring builder how to replace a characte with another character in javachange single character in string jaavajava change a character in stringjava replace character in string with indexreplace char of string javahow to replace certain characters in a stringreplace a character in a stringjavahow to change character inside a string javareplace charat index javahow do i replace a letter in a string javareplace characters in stringjava string relplacinghow to change character of a string in javareplace a character from a stringhow to replace a character with a string in a string in javajava replace characterprogramming in java typing letter replaces old letterjava 7b 7d replacereplace specific characters with new characters javahow to change the character of a string in javareplace a charater with a string javahwo to change character in index in javareplace a string javahow to replace in string in javareplace letter in string javareplace character in string java o 281 29replace 1 character in string javajava replace something from a charjava replace substringstring how to change character in javahow to change the value of character in string in javareplace string javahow to get replace characters of string in javareplace all char in string javahow to replace a character of a string in java by indexjava string replace substringreplace string with another stringreplacing data in strng in javareplace char string javareplace a part of string in javareplace string java onlinehow to replace character in stirng javareplace string by index javajava how to substitute a character in a stringhow to replace string characters in javahow to replace a character in a string in jkavahow to replace at specific character in string in javareplace charat stringreplace charsreplace string by string javachange only one character in string javahow to change string in char javastring replace charstring replace javahow to replace a character in string in javahow to replace a single character in a string javahow to replace code in javajava replace a characterhow to replace 5c in javastring index replace javareplace a string character in javareplaaaaaace a char javareplace a character in a stringreplace string character javajava replace textreplace char in javareplace char in string index javastring replace a character javareplace letter from inded ofhow to replace a string character in javafind replace string javareplacce string in a stringreplace a character of string in javareplace method in string in javareplacing characters in a sentence javarepalce a char in a string javaupdate a character in java stirngjava string modify characterhow to replace a char in a string javset char in stringstring replace in javareplace a character in a string java using indexcode to replace in javareplace chacter in string javajava replace all character in stringhow to replace 5b in javajava replace methodhow to update a character in a string in javajava replace character in string at index replace javareplace 2c with 22 22 javahow to swap the character of a string in javahow to change value of a string in javajava replace functionreplace character in a string in javachanging character in string javareplace 2f 2f in javareplacing certain character from a word javahow to replace a letter with another in java stringjava replace one char in stringhow to replace char in a string javajava string replace character with stringrepace a letter in string in javafind and replace in javastring replace charhow to change characters in a string javahow to replace a char in string in javajava replace a character in a string at an indexreplace a string with another string in ajavahow to replace characters of string in javastring replace javareplace injava i 3dfor stringsstring replace jaajava program to replace each character in a string with its next letterhow to set char at index in javareplace char with another javahow to change character in string in javareplace 22 5c 22 javareplace a character at a specific index in a char array javastring replacejava replacejava replace a character in a stringreplacing characters in a string javawrite a java program to find a character from a sentence and replace it with another charactercan you use replace with charathow to change char in string javajava replace examplejava change one char in stringhow to replace a letter in string javahow to replace a chracter in a string javareplace 2f 2c in javareplace character in a stringhow to replace 3f with a character in string javareplace string beinging chars javareplacing a character in a string javahow to replace a string in javachange string char in java replace characters on stringjavahow to replace charracters in a string javahow to replace char in string javahow to replace characetrs in javareplace something in the stringjava program to replace a character in a stringsetting char for string javareplace particular character string javajava substring remplacecharacter replace in javajava replace in stringwrite a java program to replace certain characters from string how to find and replace a character in a string in javachange elements in a string javareplace a character in a string javareplace character at particular index in javajava change a char letter with anotherreplace certain values in a string javastring replace character at index javareplace different chars in string javareplace char with another char javahow to replace a charatcter in string in javafor replace char in stringsearching for a character in a string and replace it javahow to replace a single character in a string in javachange one letter in string javahow to switch letter position in javareplacing the characters of a string javasetting characters in stringhow to rename string class javajava replace variables in stringstring find and replace javareplace 2f in javajava string replace character with character 2b anotherhow to change char to string in java and replace a charaterjava string replacejava change single char in stringreplace full stringwith anther string replace characters in array javareplace several characters in string by index javastr replace in javareplace javachange character of a string javastring replace some caracters javahow to replace a character with another character in a string in javahow to replace letters in a string in javastring replacejavahow to replace one character in a string in javajava replace caracterestring replace other language in javajava metod replace string charactersreplace a character at a particular index in string javahow to replace elements in a string javahow to change the value of a character in a string in javahow to replace a char in a string with anotherchange a char in a string javajava replacechar replace charhow to replace acharacter in a stringreplace methods in javahow to change a character in a string javajava string replace char in stringhow to replace a character at a particular index javareplace a char with a string in javareplace char in words in javareplace chars in string javareplace any index 27java replacing characterstring contains and replace in javastring replace 2f with 5c in jaahow to replace a character in a stringstring replace javajava replace exluding charjava find and replace character in stringhow to change a character in string in java repace text in javachar replace in stringreplace a char from an stringreplace substring with indicesreplace letter string with index numberjava replace substring in stringjava replace character in stringreplace character at index in string javastring replace characterhow replace 22 26 23 in itring in javareplacing a specific value in a string javareplace a char in a string with another javareplace a character in an array by another onereplace the charcater in a stringhow to replace a character from a stringhwo to change character in stinr gjavareplace in string javahow to replace characters in a stringjava find character in string and replacejava replaces instances of char in stringreplace java examplesreplace 27 3f 27 in stringhow to replace letter in string javahow to replace a substring in java using replace methodreplace ucharhw to replace lettes in string with characters in javareplace first character in string javahow replace 24 in string in javahow to change the characters of a string in javareplace each letter in a string with a indexreplace text javareplace a character with a string in javachange the string in javacreating a method in java using replacehow to replace specific character in string in javajava replace characters stringsstring replace character in javahow to replace value in string javachange place on a character in string javareplace characters in a string javachar replace in javaupdate a character in java stringreplace strin character javahow to change chacter value in java steringstr replace javausing replace in a string in javarelapce in javachar replace javareplace a charcter in javasubstitute character code javachange char insude string javahow to replace char in sstringhow to replace a character 22 2c 22 in a string in javareplace 22 javahow to replace character from a string in javareplace a char from a stringstring replace char in javajava replace 7b 7d string javareplace char string in javahow to replace a character in a string in java at indexhow to replace char in a string by index javajava replace specific characterhow to replace a set of char in a string in javareplace a char in a stringstring replacemnet 7b 7d in javareplace character from stringfind and replace string in javareplace ch in string javareplace character in strng javawrite a java program to find a character from a sentence and replace it with another character java string replace from to indexreplace a char at an index in string javajava replace codechar replacereplace javshow to edie strings javahow to change individual letter in string javahow to replace a char in a string javajava string replace characterhow to replace string 2b to operator in javareplace a char in a string in javareplace java tutorial modify char in string javareplace a cetain character in a string javareplacing characters in a string at an index javajava replace all instance of one character with a different character in a stringjava replace one character in stringreplace a string with another string in javareplacing character in stringjavahow to replace a character at an index in javahow to replace a string with another stringhow to change value of a particular index in string javahow can i replace character of string in javamodify single char in stringreplace current string with new in javachar array replace javahow to replace a character with a 2b in javajava string replace char arrayjava change string characterreplacing single character in a string arrayjava replace set of characters in stringhow to replace characters in a string in javachange character in java stringclass that implement string replacement in javareplace a char in string javastring methods java replace indexreplace in java stringreplace method in javareplace string with symbolreplace string specific position javastring replace 28char 2c char 29canging character on a string in javaset character in javastring method to replace a letter in javahow to chane any charater of a stringjava set char by indexjava how to change letters in a stringjava modify string at indexhow to set a character in a string in javahow to replace some character to an another character in javacan i change string char in javahow to over write a given string in javausing a for loop to replace a character in a string javareplace chars method javahow to change a char at ith pos in a string in javachange char in string javajava replace specific character in stringhow to change the character in a string javahow to use replace in javajava replace a single character in stringreplace char in string in javareplace letter in javareplace 24 in string javajava replace char with an charreplace text in string javahow to replaca a letter with a letter javahow to replace a letter at specific place in a string javastring replace at indexjava string substitutereplace all of a certain charector with another java in stringhow update char in stringshow to replace a character in javachange characters of a string javahow to replace a character in a string in java without using replace methodset character methode in string javause if method to change character in string javachanging single character of a stringstr replace in javahow to replace a character with another character in a string in java