DUET PG Score Card 2021
NHAI Recruitment 2021
Bihar Board 12th Dummy Admit Card 2022
RBI Assistant Notification 2021
Jee Advanced 2021 Result
NIACL Assistant Recruitment 2021
SBI PO Online Form 2021

Write a class ReversePrint with a public method reversePrint that takes one parameter arr of type int[] and returns the elements of arr in reverse order

Write a class ReversePrint with a public method reversePrint that takes one parameter arr of type int[] and returns the elements of arr in reverse order. The return type of ReversePrint should be int.

Assumptions:

  1. arr is never null

Here is an example:

Cmd Args : 32 56 85 1
Array in reverse order is : 
1
85
56
32

Note: Please don’t change the package name.

Solution:

package q11047;
public class ReversePrint { 
    
    /** * write a logic to find the array of elements in reverse order.
    * 
    *
    * 
    @return the reverseArray */
    
	public int[] reversePrint(int[] arr) { 
	    //Wrtie code here 
	    
	    int[] ReversePrint = new int[arr.length];
	    
	    for(int i = 0; i<arr.length; i++){ 
	        
	        ReversePrint[i] = arr[arr.length-1-i]; 
	    } 
	        return ReversePrint;
	        }
}

Candidates having any kind of query so he/she can ask in our comment section. Our Panel will b reverting back as soon as possible. Thank You. For more details visit our website (https://speedjobalert.com/)

Leave a Comment