Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started