相关代码 |
|
//StringBufferOp.java //反转字符串中的字符 public class StringBufferOp { public static void main(String args[]) { String s = "0123456789"; System.out.println("原来s="+s); int i = s.length(); StringBuffer buffer = new StringBuffer(i); for(int j=i-1;j>=0;j--) { buffer.append(s.charAt(j)); } System.out.println("反转后s="+buffer); } }
相关资源 |
|