加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

数组倒置解决方案

发布时间:2020-12-13 19:45:46 所属栏目:百科 来源:网络整理
导读: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(St

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]+" "); } } }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读