Search Java Code Snippets

  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.

#Java - Code Snippets for '#Replace characters in a string' - 1 code snippet(s) found

 Sample 1. Write a Program to replace characters in a String ( without using String replace method )

public class ReplaceCharacters{
   public static void main(String[] args){
      String str = "Hello BuggyBread";
      char[] charArray = str.toCharArray();
      int countCharacter = str.length();
      for(int count=0;count<countCharacter;count++){
         if(charArray[count] == 'g'){
            charArray[count] = 'd';
      String replacedString = new String(charArray).toString();

   Like      Feedback     string  replace characters in a string

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner