java字符串输出逆序转换及输出:实例

时间:2025-04-04 11:01:53
package com.company; import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Main { public static void main(String[] args) { // write your code here String [] s= new String[]{ "a","b","c","d","e" }; List<String> list = Arrays.asList(s); Collections.reverse(list); s=list.toArray(new String[0]);//没有指定类型的话会报错 for(String x: s) { System.out.println(x); } } }