就是一个在命令行输入,逆序输出的小程序,调补出来。请大家帮忙改改,谢谢谢谢!!!import java.io.BufferedReader;
import java.io.InputStreamReader;
public class R{
public static void main(String args[]) {
BufferedReader buf = null;
buf = new BufferedReader(new InputStreamReader(System.in));
String str = null;
System.out.print("请输入内容: ");
try {
str = buf.readLine();
StringBuffer sb = new StringBuffer(str);
}catch(Exception e) {
e.printStackTrace();
}
System.out.println("输入的内容为: "+str);
System.out.println("逆序后的内容为: "+sb.reverse());
}
}

解决方案 »

  1.   


    public static void main(String args[]) {
    BufferedReader buf = null;
    buf = new BufferedReader(new InputStreamReader(System.in));
    String str = null;
    System.out.print("请输入内容: ");
    StringBuffer sb = new StringBuffer();
    try {
    str = buf.readLine();
    sb.append(str);
    } catch (Exception e) {
    e.printStackTrace();
    }
    System.out.println("输入的内容为: " + str);
    System.out.println("逆序后的内容为: " + sb.reverse());
    }
      

  2.   

    put the last two"system.out.print" in the "try "