Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

4. Are there any disadvantages?

Answered: 1 week ago

Question

3. What are the main benefits of using more information technology?

Answered: 1 week ago

Question

start to review and develop your employability skills

Answered: 1 week ago