Ask Question
28 April, 23:44

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

+3
Answers (1)
  1. 29 April, 00:09
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers