Array inversion
•
Java
import java.util.ArrayList; import java.util.Collections; public class array_reverse { public static void main(String[] args) { ArrayList<String> arrayList=new ArrayList<String>(); arrayList.add("A"); arrayList.add("B"); arrayList.add("C"); arrayList.add("D"); arrayList.add("E"); System.out.println("反转前序列:"+arrayList); Collections.reverse(arrayList); System.out.println("反转后序列:"+arrayList); } }
The output result is:
Pre inversion sequence: [a, B, C, D, e] post inversion sequence: [e, a]
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码