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
masya89 [10]
3 years ago
10

The list method reverse reverses the elements in the list. Define a function named reverse that reverses the elements in its lis

t argument (without using the method reverse!).
Computers and Technology
1 answer:
Alisiya [41]3 years ago
7 0

Answer:

public class Reverse {

  1.    public static void reverseList(int list [], int n)
  2.    {
  3.        int[] reversedList = new int[n];
  4.        int k = n;
  5.        for (int i = 0; i < n; i++) {
  6.            reversedList[k - 1] = list[i];
  7.            k = k - 1;
  8.        }
  9.        //printing the reversed list
  10.        System.out.println("The Reversed list \n");
  11.        for (int j = 0; j < n; j++) {
  12.            System.out.println(reversedList[j]);
  13.        }
  14.    }

Explanation:

Using Java, An array is implemented to hold a list of items

A method reverseList() is created to accept an array as parameter and using a for statement reverses the elements of the array and prints each element of the list

See below a complete code with a main method that calls this method

<em>public class Reverse {</em>

<em>    public static void main(String[] args) {</em>

<em>        int [] arr = {10, 20, 30, 40, 50};</em>

<em>        reverseList(arr, arr.length);</em>

<em>    }</em>

<em>    public static void reverseList(int list [], int n)</em>

<em>    {</em>

<em>        int[] reversedList = new int[n];</em>

<em>        int k = n;</em>

<em>        for (int i = 0; i < n; i++) {</em>

<em>            reversedList[k - 1] = list[i];</em>

<em>            k = k - 1;</em>

<em>        }</em>

<em>        //printing the reversed list</em>

<em>        System.out.println("The Reversed list \n");</em>

<em>        for (int j = 0; j < n; j++) {</em>

<em>            System.out.println(reversedList[j]);</em>

<em>        }</em>

<em>    }</em>

<em>}</em>

You might be interested in
How to count the total number of users from backend reactjs.
igomit [66]

Explanation:

If you are only using firebase auth, you can use the listUsers function of the admin module (limited to 1000 items per page).

3 0
2 years ago
What is the purpose of an arraignment?
IgorC [24]

Answer:

At an arraignment, the court officially illuminates a litigant regarding charges contained in a prosecution or data, gives the respondent a duplicate of the charging instrument, and takes the litigant's response to those charges as a request.

Explanation:

5 0
3 years ago
Read 2 more answers
// Exercise 4.16: Mystery.java
nignag [31]

Answer:

385

Explanation:

There was no question so I simply run the program for you and included the output.

The program seems to calculate: \sum\limits_{x=1}^{10} x^2

8 0
2 years ago
Imagine you are responsible for making a presentation that includes a representation of the logic flow through a process. You un
svetoff [14.1K]

Answer:

find reliable resources

Explanation:

if you find reliable resources, than you might able to have more help i know im not answering..but im trynna help

3 0
2 years ago
Describe network in terms of the class computer lab
kobusy [5.1K]
<span>a group or system of interconnected people or things</span>
6 0
3 years ago
Other questions:
  • P3. In Section 4.2 , we noted that the maximum queuing delay is (n–1)D if the switching fabric is n times faster than the input
    8·1 answer
  • This program will get you used to retrieving a value from a function. The function should be named getRandomNumber. The function
    15·1 answer
  • How to stay organized in an online school?
    7·1 answer
  • What type of device does a computer turn to first when attempting to make contact with a host with a known IP address on another
    9·2 answers
  • A computer with a frequency 2 GHZ and its average cycle per instruction is 2. what is the MIPS of the computer?
    6·1 answer
  • Write a program that will read two floating point numbers (the first read into a variable called first and the second read into
    13·1 answer
  • Can you please help me with the AP Computer Science Fill in the blank. What goes on number 5 8 and 18. I don’t understand this I
    8·1 answer
  • Every time a key is pressed on the keyboard, the _______________ chip in the keyboard notices which key has been pressed.
    13·1 answer
  • (Synchronized threads) Write a program that launches 1000 threads. Each thread adds a random integer (ranging from 1 to 3, inclu
    5·1 answer
  • a company recently implemented a secure sockets layer/transport layer security (ssl/tls) version that supports secure hashing al
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!