如何编写代码,让这几组无序列表变成图2的横向排列

1.最简单的方法:public static String reverse1(String str){ return new StringBuffer(str).reverse().toString();} 2.最常用的方法:public static String reverse3(String s){ char[] array = s.toCharArray();String reverse = ""; //注意这是空,不是null for (int i = array...
如何编写代码,让这几组无序列表变成图2的横向排列
1.最简单的方法:
public static String reverse1(String str)
{ return new StringBuffer(str).reverse().toString();
}
2.最常用的方法:
public static String reverse3(String s)
{ char[] array = s.toCharArray();
String reverse = ""; //注意这是空,不是null
for (int i = array.length - 1; i >= 0; i--)
reverse += array[i];
return reverse;
}
3.常用方法的变形:
public static String reverse2(String s)
{ int length = s.length();
String reverse = ""; //注意这是空,不是null
for (int i = 0; i < length; i++)
reverse = s.charAt(i) + reverse;//在字符前面连接, 而非常见的后面
return reverse;
}2014-10-28
mengvlog 阅读 50 次 更新于 2025-12-15 05:06:33 我来答关注问题0
檬味博客在线解答立即免费咨询

CSS相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部