Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote