1 answer

Java code Write a method called reverse that takes an array of integers as an input...

Question:

java codeWrite a method called reverse that takes an array of integers as an input and returns the same values in reverse order as the

Write a method called reverse that takes an array of integers as an input and returns the same values in reverse order as the output. Test your method in the main.

Answers

Reversing an array using Java

Answer:

          Below the method uses the function java.util.Collections.reverser(List list) method. This method reverses the elements in the specified list. At first we convert the array into a list by using java.util.Arrays.asList(array) and then we reverse the list.

import java. util.*;

public class reverseArray {

             /*function to reverse the elements in an array*/

            static void reverse(Integer array[])

            {

                        /*Converting the array into list and reversing the elements*/

                          Collections.reverse(Arrays.asList(array)) ;

                              /*printing the reversed list*/

                          System.out.println(Arrays.asList(array) ;

             }

/*calling main function*/

             public static void main(String[] args)

             {

                         Integer[] array = {2, 4, 5, 7, 8, 9, 3, 10} ;

                             /*calling reverse method*/

                         reverse(array) ;

              }

}

Output:

[10, 3, 9, 8, 7, 5, 4 ,2]

                     

.

Similar Solved Questions

1 answer
In a differential scanning calorimetry experiment, the melting temperature, Tm, of a certain protein is found...
In a differential scanning calorimetry experiment, the melting temperature, Tm, of a certain protein is found to be 46 C and the enthalpy of denaturation is 382 kJ/mol. a. Estimate the entropy of denaturation assuming that the denaturation is a two-state process; that is: native protein<=>dena...
1 answer
Question Completion Status: If you buy a $400,000 condo with 100% financing over 30 years at...
Question Completion Status: If you buy a $400,000 condo with 100% financing over 30 years at 10% interest per year, what will your annual payments be? Assume you are allowed to make annual payments. 42,432 58,989 88,455 89,560 QUESTION 11 What is the effective annual rate (EAR) for a 12% APR assumin...
1 answer
The Dawg corporation has Gross Income of $4,250,000 not including Municipal Bond Interest of $40,000, and...
The Dawg corporation has Gross Income of $4,250,000 not including Municipal Bond Interest of $40,000, and deductions of $950,000. Calculate Dawg's tax liability. A B D E 1 Taxable Liability 2 3 4 6 7 8 10...
1 answer
12. (S)-2-butanol is first reacted with methanesulfonyl chloride and this is followed by reacting it with...
12. (S)-2-butanol is first reacted with methanesulfonyl chloride and this is followed by reacting it with methane thiolate in methane thiol. Show the detailed mechanisms for these transformations....
1 answer
Please help with finding Part J (highlighted) -Change vs 2015 represents the monetary amount vs. the...
Please help with finding Part J (highlighted) -Change vs 2015 represents the monetary amount vs. the year ago All $000 % Sales Change vs 2015 % Ch. Fiscal Year2016 Year 3 17,690 Sales 100.0% $ 3,308 23.0% FY 2015 % Sales Change vs 2014 % Change FY 2014 % Sales Year 2 Year 1 $14,382 100.0% $ 2,688 23...
1 answer
Your supervisor tasked you to design a square cross-section silicon p-n junction diode with the following...
Your supervisor tasked you to design a square cross-section silicon p-n junction diode with the following specifications: 1. Intrinsic concentration at 300K: n. = 1.5x 10"/cmº. 2. p-side doping: N = 101/cm. 2. n-side doping: No = 1021/cm. 3. QNR length: W, =W, = 1 um. (a) Determine the side...
1 answer
Marks People Univers X -Assignments-PHYS-155(02,0 x usask.ca/bbcswebdav/pid-2494580-dt-content-rid-118336 D PHYS155,2019A2Jm.pdf , Google影, × 40201 901/PHYS 155-2019-A2_T%281%29.pdf tabel...
marks People Univers X -Assignments-PHYS-155(02,0 x usask.ca/bbcswebdav/pid-2494580-dt-content-rid-118336 D PHYS155,2019A2Jm.pdf , Google影, × 40201 901/PHYS 155-2019-A2_T%281%29.pdf tabel your submission by printing your class, section, name, nsia, and student number in the upper right-...
1 answer
Please show me your work for L. I have the correct answer but i do not...
Please show me your work for L. I have the correct answer but i do not know how to get to it. Please explain. Thank you, I will rate. Da POINTS 3/3 POINTS PREVIOUS ANSWERS PREVIOUS ANSWERS ASK YO A new liquid substance has been discovered that freezes at 25°C. A scientist poured the liquid (whic...
1 answer
​(New project analysis​) Garcia's Truckin' Inc. is considering the purchase of a new production machine for...
​(New project analysis​) Garcia's Truckin' Inc. is considering the purchase of a new production machine for ​$250,000.The purchase of this machine will result in an increase in earnings before interest and taxes of ​$60,000 per year. To operate the machine​ prop...
1 answer
4.1.2 Atwelve-year 100 par value bond pays 7% coupons semiannually. The bond is priced at 115.84...
4.1.2 Atwelve-year 100 par value bond pays 7% coupons semiannually. The bond is priced at 115.84 to yield an annual nominal rate of 6% compounded semiannually. Calculate the redemption value of the bond....
1 answer
10. Which of the following does not obey the octet rule? a) PCI b) H0 c)...
10. Which of the following does not obey the octet rule? a) PCI b) H0 c) NH, d) CCI, 11. Which one of the following is the most polar a) H-F b) H-CI c) H- Br d) H-...
1 answer
Fully explain please trying to study CHAPTER END REVIEW Best Sleep Company manufactures two mattress toppers...
Fully explain please trying to study CHAPTER END REVIEW Best Sleep Company manufactures two mattress toppers called Alpha and Beta that sell for $210 and$172, respectively. Each product uses only one type of raw material that costs $8 per pound. The company has the capacity to annually produc...
1 answer
Please correct this problem and provide a clear explanation. Show all necessary work Celebration 3 Spring...
Please correct this problem and provide a clear explanation. Show all necessary work Celebration 3 Spring 2016 Physics 212 i) Three long parallel current-carrying wires, labeled I, l2, and ls, are equally spaced distance d from each other, and all carry equal magnitude currents perpendicular to pla...
1 answer
Jounral entry acconts | | ABC Engineering completed the following transactions in the month of June....
Jounral entry acconts | | ABC Engineering completed the following transactions in the month of June. Judy Carol, the owner, invested $220,000 cash, office equipment with a value of $7,600, and $72,000 of drafting equipment to launch the company in exchange for common stock. The company purchased lan...
1 answer
81E66843-14E5-473F-A6AC-840690655100 OXO quiz3-438de #1213 3 of 4 In-Class Quiz 3 Aggregate Expenditures in a country can...
81E66843-14E5-473F-A6AC-840690655100 OXO quiz3-438de #1213 3 of 4 In-Class Quiz 3 Aggregate Expenditures in a country can be described by the following ou (Lectures 5 and 6), where the symbols have their usual meaning AE = C + mpc x (1 – t)Y + I + G + E - my With 0 < mpc < 1,0<t< 1...
1 answer
The Booth Corporation, a C corporation, is owned 100% by Ralph Hill and had taxable income...
The Booth Corporation, a C corporation, is owned 100% by Ralph Hill and had taxable income in 2019 of $550,000. Ralph is also an employee of the corporation. In December 2019, the corporation has decided to distribute $460,000 to Ralph and has asked you whether it would be better to distribute the m...
1 answer
Given 2 numbers #(a,b)# it is possible to perform geometrically the following algebraic operations: a+b, a−b, a*b, a/b. Use only a straight edge and compass to show each operation?
Given 2 numbers #(a,b)# it is possible to perform geometrically the following algebraic operations: a+b, a−b, a*b, a/b. Use only a straight edge and compass to show each operation?...
1 answer
1 7) Show that the series converges/diverges 1 1 8) Show that the sequence a N...
1 7) Show that the series converges/diverges 1 1 8) Show that the sequence a N + 1 N+ 1 is monotonic....