Ask Question
11 February, 02:09

Write a program HelloPrinter that switches the letters "e" and "o" in a string. Use the replace method repeatedly. Demonstrate that the string " Hello", world!" turns into " Holle, werld!"

+2
Answers (1)
  1. 11 February, 05:30
    0
    public class Printing

    {

    public static void main (String[] args)

    {

    String letters = "Hello, World!";

    String letters2 = letters. replace ("o", "e");

    String letters3 = letters. replace ("e", "o");

    System. out. println (letters3);

    }

    }

    Explanation:

    We start by defining a class called Printing. We take a string variable to store "Hello, World!";. Then we use replace method 2 times to switch the letters "e" and "o". Finally we print the last String variable where the latest replacement is stored.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program HelloPrinter that switches the letters "e" and "o" in a string. Use the replace method repeatedly. Demonstrate that the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers