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
Why did industrial revolution begin Britain?​
allochka39001 [22]

Answer:

Britain also happened to have a wealth of coal, iron, and other resources in a relatively small area, which would help kick-start the Industrial Revolution. Its growing Colonial Empire also provided a ready-made (and captive) market for surplus goods, providing further impetus for entrepreneurs and new industrialists

7 0
1 year ago
Read 2 more answers
Consider the following class interfaces:
o-na [289]

Answer:

class teacher and student I didn't actually read it but I think it is class student

6 0
3 years ago
Which technology can be used as a defense against dos and ddos syn flood attacks?
Montano1993 [528]
In terms of websites, there's a service called cloud flare which can prevent DDOS attacks in websites. Other applications you would have to look up. Hopefully this helps!
6 0
3 years ago
How long does the Splunk search job remain active
Degger [83]
When you run a new search job, the job is retained in the system for a period of time, called the job lifetime. f the job is not accessed within the specified lifetime, the job expires and is removed from the system. There are two lifetime settings, 10 minutes and 7 days. The lifetime starts from the moment the job is run.
8 0
3 years ago
The processing is done in the​
Lady_Fox [76]

Answer:

CPU Central Processing Unit

5 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is an important initial step in designing an interface
    7·1 answer
  • ____ is a special type of large, integrated system that ties together all types of a company’s activities, such as planning, man
    11·2 answers
  • Select the correct answer.
    9·1 answer
  • What would happen if you clicked on the Show Desktop icon on your computer screen? The system tray would appear. All open window
    9·2 answers
  • In a natural-language processing (NLP) system, the__________activity involves using the computer to read large amounts of text a
    9·1 answer
  • Which of the following is an example of hypertext pattern reading?
    13·1 answer
  • How major is the technology problem in the United States?
    15·1 answer
  • Where is the "delete account" button in my profile? And please give me a legit answer and not just a word.
    10·2 answers
  • All cells in row 2 through 5 are referred as 2:5 true or false
    10·1 answer
  • What is the output of the following code snippet if the variable named cost contains 100? if cost &lt; 70 or cost &gt; 150 : dis
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!