Write a method that takes two string arrays as input parameters and returns a bo
ID: 3536047 • Letter: W
Question
Write a method that takes two string arrays as input parameters and returns a boolean value indicating if the strings in corresponding locations of the two arrays are identical or not.
I tried working this out and didn't get the full credit so can someone tell me where to correct it please. My teacher said to check conditions and she underlined the return boolean part so I'm not sure what that means. Thank you for your help!
public static boolean identical(String [] a, String [] b) {
for (int i = 0; i < a.length; i++) {
if (a[i].equals b[i])
boolean true;
else
boolean false;
}
return boolean;
}
Explanation / Answer
public static boolean identical(String a[], String b[])
{
bool boolean
for (int i = 0; i < a.length; i++)
{
if (a[i]== b[i])
boolean= true;
else
boolean =false;
}
return boolean;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.