Complete the following java code such that are


Complete the following Java code such that are TwoArraysSame() method receives two arrays of String data type and then returns true if the two arrays contain the exactly same contents. Otherwise, it returns false. (Hint: You should first check if two arrays contain the same number of elements.)

public boolean areTwoArraysSame(String[] array1, String[] array2)

{

boolean arraysEqual = true;

            int i = 0;

            int whereFalse = 0;

            if (array1.length != array2.length){

arraysEqual = false;}

            while (arraysEqual && i < array1.length)

            {

              if (array1[i] != array2[i])

{

               arraysEqual = false;

   whereFalse = i;

 }

                         i++;

            }

            }

Solution Preview :

Prepared by a verified Expert
Macroeconomics: Complete the following java code such that are
Reference No:- TGS01543438

Now Priced at $10 (50% Discount)

Recommended (96%)

Rated (4.8/5)