Question: X 6 4 9 : Longest string Given an array of Strings, return the longest String in the array. If the array is empty, return
X: Longest string
Given an array of Strings, return the longest String in the array. If the array is empty, return null.
Examples:
longestabcaba "abc"
Your Answer:
String longestString names
f
if names length
f
return ;
line : error: incompatible types: int cannot be converted to java.lang.String
int max numbers ;
for int ; names. length;
if numbers imax
f
max numbers ;
return max;
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
