Home > Java > javaTutorial > Java classic programming question--output an array in reverse order

Java classic programming question--output an array in reverse order

零下一度
Release: 2017-06-25 10:36:13
Original
7917 people have browsed it

Output an array in reverse order.

public class Example31 {
public static void main(String[] args) {
int[] a = { 9, 4, 6, 8, 3, 21, 16, 12 };
        covertArray(a);
  }

    public static void covertArray(int[] a) {
      System.out.print("The original array is: ");
      for (int r : a) {
        System.out.print(r + " ");
      }
    System.out.print("\nThe reverse order of the array is: ");
                                              int i = a.length - 1; i >= 0; i--) {
            System.out.print(a[i] + " ");

The above is the detailed content of Java classic programming question--output an array in reverse order. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template