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
I watched an ad but the im button done is no where in sight, has anyone else experienced this recently. it was fine a few days a
Maurinko [17]

Answer:

This is usually just a small glitch that happens sometimes when you are seeing an ad and wanting to skip. Simple fixes to this problem include refreshing the browser or closing the application that you are in. This also would happen to me but following this fix should help with the problem.

7 0
2 years ago
What is the name of a button on a website?
zhuklara [117]
May I know which button?
5 0
3 years ago
Given an input array of strings (characters) s, pick out the second column of data and convert it into a column vector of data.
hodyreva [135]

Answer:

Consider the following code.

Explanation:

save the following code in read_and_interp.m

 

function X = read_and_interp(s)

[m, n] = size(s);

X = zeros(m, 1);

for i = 1:m

if(str2num(s(i, 2:5)) == 9999)

% compute value based on previous and next entries in s array

% s(i, 2:5) retrieves columns 2-5 in ith row

X(i,1) = (str2num(s(i-1 ,2:5)) + str2num(s(i+1,2:5)))/2;

else

X(i,1) = str2num(s(i,2:5));

end

end

end

======================

Now you can use teh function as shown below

s = [ 'A' '0096' ; 'B' '0114' ; 'C' '9999' ; 'D' '0105' ; 'E' '0112' ];

read_and_interp(s)

output

ans =

96.000

114.000

109.500

105.000

112.000

7 0
3 years ago
Select the correct answer.
ss7ja [257]
The answer a identifying portfolio goal
8 0
3 years ago
Read 2 more answers
Which of the following need to be assessed during unit testing?
diamong [38]
E) both C and D Erro handling and execution paths
8 0
3 years ago
Other questions:
  • Summarizes statistical data ?
    11·1 answer
  • Which element in the PowerPoint application is not available in the Microsoft Word application?
    12·2 answers
  • Machines may aid in making work easier over a longer distance. true or false.
    7·1 answer
  • A stateless firewall inspects each incoming packet to determine whether it belongs to a currently active connection.
    9·1 answer
  • When should you save your document?
    15·2 answers
  • Where are the results from the Advanced Find feature displayed?
    6·1 answer
  • Write a method named removeRange that accepts an ArrayList of integers and two integer values min and max as parameters and remo
    10·1 answer
  • 11) A single inheritance model means: * A) A class can only have one parent class (superclass) B) A class can only have one chil
    7·1 answer
  • The first version of Windows to have a Start button and taskbar was?
    5·1 answer
  • What is the value of the variable named result after the following code executes?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!