如题所述
package test0324;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PrintTest {
/**
* @param args
*/
public static void main(String[] args) {
InputStreamReader ir;
BufferedReader in;
ir = new InputStreamReader(System.in);//创建输入流对象
in = new BufferedReader(ir);
System.out.println("请输入字符串:");
try {
String s = in.readLine();
System.out.println("您输入的字符串长度是:"+s.length());
System.out.print("逆序输出为:");
for(int i=s.length();i>0;i--){
System.out.print(s.substring(i-1, i));
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PrintTest {
/**
* @param args
*/
public static void main(String[] args) {
InputStreamReader ir;
BufferedReader in;
ir = new InputStreamReader(System.in);//创建输入流对象
in = new BufferedReader(ir);
System.out.println("请输入字符串:");
try {
String s = in.readLine();
System.out.println("您输入的字符串长度是:"+s.length());
System.out.print("逆序输出为:");
for(int i=s.length();i>0;i--){
System.out.print(s.substring(i-1, i));
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
温馨提示:答案为网友推荐,仅供参考