public class Test{ public static void main(String[] args){ String str="hello world"; for(int i=str.length()-1;i>=0;i--){ System.out.print(str.charAt(i)); } } }本回答被提问者采纳
第2个回答 2008-11-29
或者利用StringBuffer里的reverse()函数: public class Test{ public static void main(String[] args){ String s = "abcdefg"; StringBuffer sb = new StringBuffer(s); System.out.println(sb.reverse()); } }