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
solmaris [256]
2 years ago
13

Write a method reverse that takes an array as an argument and returns a new array with the elements in reversed order. Do not mo

dify the array.
Computers and Technology
1 answer:
mr Goodwill [35]2 years ago
4 0

Answer:

public class ArrayUtils

{

//function to reverse the elements in given array

public static void reverse(String words[])

{

//find the length of the array

int n = words.length;

//iterate over the array up to the half

for(int i = 0;i < (int)(n/2);i++)

{

//swap the first element with last element and second element with second last element and so on.

String temp;

temp = words[i];

words[i] = words[n - i -1];

words[n - i - 1] = temp;

}

}

public static void main(String args[])

{

//create and array

String words[] = {"Apple", "Grapes", "Oranges", "Mangoes"};

//print the contents of the array

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

{

System.out.println(words[i]);

}

//call the function to reverse th array

reverse(words);

//print the contents after reversing

System.out.println("After reversing............");

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

{

System.out.println(words[i]);

}

}

Explanation:

You might be interested in
Which of the following best describes the purpose of an IP address?
garri49 [273]

IP addresses provide a unique number for identifying devices that send and receive information on the Internet

-scav

8 0
3 years ago
Read 2 more answers
Suppose you draw two cards from a standard deck of 52 playing cards. What is the probability that they are both sixes? Keep at l
GaryK [48]

Answer:

0.00452

Explanation:

There are 4 sixes in a deck. So the chance that the first card you draw is a six, is 4/52. Then there are only 3 sixes left and 51 cards. So the chance that the second one is also a six is 3/51.

The combined chance is the multiplication, i.e., 4/52 * 3/51 = 0.00452

7 0
3 years ago
Where might the Null Object pattern be useful?
Tanzania [10]

Answer:  Null Object pattern be useful when the absence of an object can be encapsulated by other alternatives which does not have any have any effect.

Explanation:

public interface Rectangle {

double area();

   double surfaceare();

   boolean isNull();

}

In the code above we have a function for null object. So in the absence of an object we have encapsulated with a method of null which does not do anything. It simplifies the use of dependencies that can be undefined.

In case of collaborator the NULL object pattern makes use of the existing collaboration instead of defining a new one.

It also enable to abstract the handling of null objects from the client so that internal details of the program are not know to outsiders.

5 0
2 years ago
Which statement is true about the filtering technique? A. You cannot apply multiple filters. B. You cannot remove a filter once
Naily [24]

Answer:

<u>C. You cannot unhide rows by removing filters</u> is the correct statement about filtering technique.

Explanation:

We can apply multiple filters for rows or columns. If we would like to view the data satisfying multiple filters, this option can be used.

Once a filter is applied, it can be removed or added again. The hidden rows or columns will be visible once all the filters are removed. By building a selection list of all the rows that should not be visible, we can hide the rows by removing filters.  

Filters can be applied to any row or column.

5 0
3 years ago
3. with a dui charge on a driver’s record ______________. a. the price of his or her insurance greatly increases b. he or she ma
djyliett [7]
<span>The answer to your question is D. both A and C</span>
7 0
3 years ago
Other questions:
  • Who is the father of modern computer?​
    5·2 answers
  • Write code that inserts userItem into the output string stream itemsOSS until the user enters "Exit". Each item should be follow
    5·1 answer
  • George wants to edit the font of the title text in his presentation. Where can he find the option to edit it?
    6·2 answers
  • 1.Discuss the differences and similarities between a peer-to peer network and a client server network.
    8·1 answer
  • "Using the printf method, print the values of the integer variables bottles and cans so that the output looks like this: Bottles
    12·1 answer
  • Design the program in the following way:
    8·1 answer
  • When you login to your blogging account. The first screen with all controls, tools and functions is called .... Select one: a. D
    10·1 answer
  • Why is it important to think about the programming language to use?
    8·1 answer
  • Write a function magicCheck that takes a one-dimensional array of size 16, a two-dimensional array of four rows and four columns
    10·1 answer
  • What is a program that includes a function parameter capable of doing?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!