Prompt Submissions/Test Runs (0) > RUN D Files + 白个业 Online (1) Ahmed rashed 202000383 0 Main.java : Write a method head
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Prompt Submissions/Test Runs (0) > RUN D Files + 白个业 Online (1) Ahmed rashed 202000383 0 Main.java : Write a method head
Prompt Submissions/Test Runs (0) > RUN D Files + 白个业 Online (1) Ahmed rashed 202000383 0 Main.java : Write a method header on line two with the following specs: Returns: a String Main.java 1 class Main 2 3 { 4 5 } 6 7 //test case below (dont change): 8 public static void main(String[] args) { 9 System.out.println(surroundStr("abcabcabc", "abc")); //"(abc)(abc)(abc)" 10 System.out.println(surroundStr("there, on planeth hoth", "th")); //"(there, on plane(th) ho(th)" 11 } 12 } Name: surroundstr Parameters: a String called s a String called search_term | Then complete the method by programming the following behavior Return a new String built from s that has every instance of the search term surrounded by parentheses See below examples. Examples: CONSOLE SHELL C VIEW DESKTOP surroundstr("abcabcabc", "abc") ==> "(abc)(abc)(abc)" surroundstr("there, on planeth hoth","th") ==> "(th) ere, on plane(th) ho(th)" Please note that you are not allowed to use the String method replace() or replaceAll() in your solution.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!