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
(Just wondering and for fun) What can humanity do to survive after the universe dies? Assuming we have advanced tech and there a
Troyanec [42]

Answer:

If this is for fun. then may I take points for free. If not, then I will post my answer :)

Explanation:

5 0
2 years ago
The process of engineering design typically starts with what ?
klemol [59]

The process of engineering typically starts with brainstorming.
6 0
2 years ago
Jjhb ft fv tuning Denise l Debbie
Vitek1552 [10]
What








What the debbie



7 0
3 years ago
Given a list ` = (x1 x2 . . . xn−1 xn), we define two rotations of the list: The left-rotation is (x2 . . . xn−1 xn x1) and, lik
aleksandrvk [35]

Explanation:

The below code has been written in C language

void rotateright(int list[], int n)

{

  int x = list[n-1]

  int i;

  for (i = n-1; i > 0; i--)

     list[i] = list[i-1];

  list[0] = x;

}

void rotateleft(int list[], int n)

{

  int x = list[0]

  int i;

  for (i = 1; i < n-1 ; i++)

     list[i] = list[i+1];

  list[n-1] = x;

}

int main()

{

   int list[] = {x1, x2, x3, ... x(n-1),xn}

   int i;

   int n = sizeof(list);

       

   rotateright(list, n);

 

   rotateleft(list, n);

   

   return 0;

}

3 0
3 years ago
How can earn more answer from brainly less than two minutes, please
Andrei [34K]
You have to answer other people’s questions.
6 0
3 years ago
Other questions:
  • ________ is typically used as the last string of letters in the name of a website. Group of answer choices the name of the indiv
    13·1 answer
  • What computer has best software
    5·1 answer
  • The graph of which function has an axis of symmetry at x=-1/4​
    15·1 answer
  • The ____ command displays the last 10 lines of a text file.
    5·1 answer
  • In the United States, everyone is guaranteed work true or false
    13·1 answer
  • Part 1 Given 3 integers, output their average and their product, using integer arithmetic. Ex: If the input is 10 20 5, the outp
    6·1 answer
  • What is the term used to describe a computer system that can store literary documents, link them according to logical relationsh
    5·1 answer
  • Disk ____ is the ability to spread data over multiple disks or volumes
    7·1 answer
  • Which of the following types of computers is typically used by governments and hospitals and can support hundreds of users?
    6·2 answers
  • Is monitor is a television​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!