Because the first time to write a blog, and we hope to make progress together and work together.
First, you can
public class Revcarr {public static void main (string[] args) {//TODO auto-generated method Stubint []arr = {11,22,33,44,5 5,66,77};for (int x=0;x<arr.length;x++) {System.out.println (arr[x]);}}}
To have a control group, the results of the operation are as follows:
This is the normal array to do is to invert all the numbers. Instead of flipping like this:
public class Revcarr {public static void main (string[] args) {//TODO auto-generated method Stubint []arr = {11,22,33,44,5 5,66,77};for (int x=0;x<arr.length;x++) {//control group SYSTEM.OUT.PRINTLN (arr[x]+ ""); System.out.println ("*");} for (int x=arr.length-1;x>=0;x--) {System.out.println (arr[x]+ "");}}}
Such a rollover, although the result can be turned upside down, but also the arr[0] and other address order is also flipped. But the result is:
So it's best to flip it this way:
public class Revcarr {public static void main (string[] args) {//TODO auto-generated method Stubint []arr = {11,22,33,44,5 5,66,77};for (int x=0;x<arr.length;x++) {System.out.println (arr[x]); System.out.println ("*");} Revcarr (arr);//This is the flip print (arr) of an array in the Flip class;//This is the printout}public static void Revcarr (Int[]arr) {for (int x=0;x< arr.length/2;x++) {int a = Arr[x];arr[x]=arr[arr.length-1-x];arr[arr.length-1-x]=a;}} public static void print (int. []arr) {for (int x=0;x<arr.length;x++) {System.out.println (arr[x]);}}}
Results:
11*22*33*44*55*66*77*77665544332211
Java Array Rollover