Write a Java program to replace all the ‘d’ characters with ‘f’ characters

Introduction

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..

public class Javaexcercise {
 
   public static void main(String[] args)
    {
        String str = "TECHSTUDY - The Complete Debugging Solution";
 
        // Replace all the 'd' characters with 'f' characters.
        String new_str = str.replace('T', 'Y');
 
        // Display the strings for comparison.
        System.out.println("Original string: " + str);
        System.out.println("New String: " + new_str);
    }
}

Result

Write a Java program to replace all the 'd' characters with 'f' characters
Write a Java program to replace all the ‘d’ characters with ‘f’ characters

Leave a Comment