数组倒置解决方案

前端之家收集整理的这篇文章主要介绍了数组倒置解决方案前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

package cn.edu.text;
/**
* 数组倒置
*/
public class ArrayRe {

public static <T> T[] arrayre(T[] o){ for (int i = 0; i < o.length/2; i++) { T tem = o[i]; o[i] = o[o.length-1-i]; o[o.length - 1 -i] = tem; } return o; } public static void main(String[] args) { String a[] = {"1","2","3","5","8","10","13"}; String b[] = arrayre(a); for (int i = 0; i < b.length; i++) { System.out.print(b[i]+" "); } } }

原文链接:https://www.f2er.com/javaschema/286209.html

猜你在找的设计模式相关文章