1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Karolina [17]
3 years ago
5

Write a method called equals that takes in two string arrays and returns true if they are equal; that is, if both arrays have th

e same length and contain equivalent string values at each index.
Computers and Technology
1 answer:
Sonja [21]3 years ago
8 0

Answer:

public boolean equals( String [ ] a, String [ ] b ){

       if (a.length == b.length){

           for (int i = 0; i < a.length; i++){

               if ( ! a [ i ].equals( b [ i ] )) {

                   return false;

               }

           }

           return true;

       }

       return false;

   }

Explanation:

The above code has been written in Java.

// 1. Method header declaration

// Method name is <em>equals.</em>

<em>// </em>It takes in two arguments which are the two string arrays <em>a</em> and <em>b.</em>

// Since the method returns a true or false, the return type is boolean

public boolean equals( String [ ] a, String [ ] b ){

       

       // 2. Check if the two arrays are of same length

       if (a.length == b.length){       // Begin outer if statement

           

           // If they are equal in length,

           // write a for loop that cycles through the array.

           // The loop should go from zero(0) to one less than

           // the length of the array - any of the array.

           for (int i = 0; i < a.length; i++){

               // At each of the cycle, check if the string values at the index which

              // is i, of the two arrays are not equal.

               if ( ! a [ i ].equals( b [ i ] )) {

                 

                   // If they are not equal, exit the loop by returning false.

                   return false;

              }

          }

          // If for any reason, the for loop finishes execution and does not

          // return false, then the two arrays contain the same string values at

          // each index. Therefore return true.

           return true;

       }                // End of outer if statement

       // If none of the return statements above are executed, return false.

       return false;

   }      // End of method.

<em>Hope this helps!</em>

You might be interested in
1. Who was able to complete the puzzle the fastest in Trial 1?
KATRIN_1 [288]

Answer:

You...answered all of the questions.

Explanation:

All of them have a response!

8 0
2 years ago
What if you have been asked to opt or design expert system or virtual reality using artificial intelligence for your daily/routi
algol13

Answer:

I would design the word asa better place

Explanation:

6 0
3 years ago
What are some of the general components of an IDE?
AysviL [449]

Answer:

An IDE normally consists of a source e editor, build automation tools. Most modern IDEs have intelligent code completion. Some IDEs contain a compiler, interpreter, or both.

5 0
3 years ago
How do hardware and software work together to allow a user to perform a function?
qaws [65]

Answer:

jointly

Explanation:

Because Hardware and Soft ware have to JOIN together to make something work

I hope i helped!

4 0
2 years ago
Read 2 more answers
In contrast to data in a database, data in a data warehouse is described as subject oriented, which means that it _____.
jonny [76]

Answer:

focuses on a certain subject

Explanation:

it means that it focuses on that one subject and none others

Hope it helps c:

6 0
2 years ago
Other questions:
  • What is a bus master?
    14·1 answer
  • What is used for World Wide Web?
    7·1 answer
  • A(n) file management system is a program that allows the creation of individual database tables, each of which is stored in its
    5·1 answer
  • What cable should i be using to connect my android tablet to the pc?
    13·2 answers
  • Average of Grades - Write a program that stores the following values in five different variables: 98, 87, 84, 100, 94. The progr
    8·1 answer
  • Effective presentations vary the color scheme on each slide.
    7·2 answers
  • What is not true about contracts?
    12·2 answers
  • • Open your Netbeans IDE and answer the following question
    5·1 answer
  • Is the Internet dangerous?
    10·2 answers
  • This is for being Weird!
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!