Question: Code Java 4) Write a program with a method called middleInsert) that inserts a string (str1) into the middle of another string (str2) at a

Code Java  Code Java 4) Write a program with a method called middleInsert)

4) Write a program with a method called middleInsert) that inserts a string (str1) into the middle of another string (str2) at a defined position (pos). The method will return a new String. You will need to handle these situations: if pos 0, insert str2 at beginning of str1. If pos> length of str1, insert str2 at the end of str1 (these are the easy cases). If either String is null throw a new I1legalArgumentException (20pts) Use these test cases: System .out.printIn(middleInsert ("A Man a plan Panama", "#4#4", 0)); System.out.println(middleInsert("A Man a plan Panama", "200)) System . out.printIn(middleInsert ("A Man a plan Panama ", "#### ", 5)); To produce this output: ####A Man a plan Panama A Man a plan Panama#### A Man#### a plan Panama acer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!