#reversearray
Explore tagged Tumblr posts
Text
Array: Reverse an array
Array: Reverse an array
Question: Write a program to reverse an array Example: original array: {1,2,3,4,5} Output:5,4,3,2,1 public static int[] reverseArray (int [] array){ int [] newArray= new int[array.length]; for (int i=0, j=(array.length-1); i< array.length; i++, j--){ newArray[j]= array[i]; } return newArray; }
View On WordPress
0 notes