请教JAVA编程题“编程实现反转一个字符串并输出”
StringBuffer的常用方法 public int capacity() 这个方法返回字符串缓冲区的当前容量。 public synchronized StringBuffer reverse() 这个方法反转字符串缓冲区中的字符串 public int length() 这个方法返回缓冲区中字符的个数 public synchronized setLength(int newLength) 这个方法设置字符串缓冲区的长度。
public synchronized charAt(int index) 这个方法返回字符串缓冲区中指定位置的字符 public synchronized void setCharAt(int index,char ch) 这个方法将字符串缓冲区中指定位置的字符设置为ch。
import .*; public class daoxu{//类名 public static void main(String args[]){ BufferedReader br =new BufferedReader(new InputStreamReader( )); String string=" "; try{ string= adLine(); } catch(IOException ex){ intln(ex); } for(int i=string.length()-1;i>=0;i--) int( arAt(i)); } }
答:以C/C++举例。 读入的字符串为s。那么s++一直到*s为'/0',既字符串终点。然后一直s--输出到首字符即可。首字符可以用字符长度判断。 如果是用char...详情>>
答:google "java 缓冲池"详情>>
答:百度里搜张孝祥 非常好的视频教程详情>>