一个字符串输出
程序要求输入一字符串要求倒着输出来!我写的下面的程序,程序没有出现错误但是
没有结果出来!只有Please input the string出现。单我输入时再敲回车时就出现This is string:
就没有的!本人不解请问是为什么!谢谢大家指教
import java.io.*;
public class Hu{
public static void main(String[] args) {
String s=" ";
StringBuffer k = new StringBuffer();
System.out.println("Please input the string:");
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
s=in.readLine();
for(int i=s.length();i>0;i--) {
k.append(s.charAt(i));
}
} catch(Exception e){}
System.out.println("This is string: "+k.toString());
}
}