The method of array flipping (Java implementation), so-called array flipping, is to invert the array, for example the original array is: {"A", "B", "C", "D"}, then the inverted array is {"D", "C", "B", "a"}. The following implementation method, here for the sake of simplicity I borrowed the list's Add method.
package org.webdriver.autotest.study; Import java.util.arraylist;public class array_examp1 { public static void main (String[] args) { // TODO Auto-generated method stub //array rollover. For example: {' A ', ' B ', ' C ', ' d '} becomes {' d ', ' C ', ' B ', ' A '} string[] array_old={"a", "B", "C", "D"}; Arraylist<string> array_new_list=new arraylist<string> (); String[] array _new=new string[array_old.length]; for (int i=1;i<=array_old.length;i++) { array_new_list.add (Array_old[array_old.length-i]); } array_new=array_ New_list.toarray (array_new); for (int j=0;j<array_new.length;j++) { system.out.print (" "); system.out.print (Array_new[j] ); } }}
Operation Result:
D C B A
Method of array flipping (Java implementation)