标题: 关于字符串 [打印本页] 作者: ↖落葉下♀媃媚 时间: 2013-4-3 19:26 标题: 关于字符串 string word = "today is beautiful very much";
怎么把单词变成"much very beautiful is today作者: 谢达 时间: 2013-4-3 19:34
public static void main(String[] args) throws Exception {
String word = "today is beautiful very much";
List<String> li = new ArrayList<String>();
String [] strs = word.split(" ");
for(int i =0;i<strs.length;i++){
li.add(strs[i]);
}
Collections.reverse(li);
for(String s : li){
System.out.print(s+" ");
}
}作者: 曾玉锋 时间: 2013-4-3 19:37
string str = "i love you";
foreach(string item in str.Split(' ').Reverse())
{
Console.Write(item+" ");
}
Console.ReadKey();
List<string> list = new List<string>(); //list用来保存单词
for (int i = wordArr.Length - 1; i >= 0; i--) //从后往前遍历数组,将单词放list中,相当于逆序了
{
list.Add(wordArr[i]);
}