Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

To replace one specific character with another throughout a string

public class MainClass {   public static void main(String[] arg) {     String text = "To be or not to be, that is the question.";     String newText = text.replace(' ', '/');     // Modify the string text          System.out.println(newText);   } } To/be/or/not/to/be,/that/is/the/question.