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. langStringBuffer
Throws
an exception if array is
getArrayStringsLongerthan javalangStringBufferl array, int length
if
array null i
null.
throw new IllegalArgumentException;
Creating a counter.
int numofvalues ;
For Loop that iterates through an array.
for int i ; 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 an array of is returned.
if
numofvalues
return
new java. lang.StringBuffer:
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 :
For Loop that goes through the array.
The StringBuffer array with the counter inside is equal to the array at index
for int i ; i array.length; i
if arrayillength 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
