Question: Write Junit Assertion Tests for public static java. lang - StringBuffer [ ] 1 5 4 Throws an exception if array is getArrayStringsLongerthan ( java

Write Junit Assertion Tests for public
static java. lang-StringBuffer []
154
Throws
an exception if array is
getArrayStringsLongerthan (java.lang-StringBufferl] array, int length)
if
(array = null) i
null.
throw new IllegalArgumentException();
// Creating a counter.
int numofvalues =0;
// For Loop that iterates through an array.
for (int i =0; i array. length; i++)(
// If the length of the specific index of array is greater, than the array
// passed in,
the counter increases.
if
(array (il. length() length)( numofValues++:
If no strings are found, or the counter is 0, an array of 0, is returned.
if
(numofvalues =0)1
return
new java. lang.StringBuffer(0]:
Creating size of
a stringBuffer
array that will end up being returned. The specific
the
StringBuffer array is the numofValues, which was created.
StringBuffer[]
arrays = new StringBuffer [numOfValues]:
// Creating a counter.
int longerthan =0:
// For Loop that goes through the array.
// The StringBuffer array with the counter inside is equal to the array at index
for (int i =0; i < array.length; i++){
if (array(il.length() length)
arrays (longerThan]= arrayli];
longerThan++;
// Returns the StringBuffer array with copies of objects in the array parameter.
return arrays;

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 Programming Questions!