Ask Question
8 July, 11:40

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!"

+5
Answers (1)
  1. 8 July, 15:33
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers