Scanner rd;
String str;
do {
System.out.println("請輸入字符(長度小於100)");
rd=new Scanner(System.in);
str=rd.nextLine();
} while(str.length() > 100);
StringBuilder rts=new StringBuilder();
for(int i=str.length(); i > 0; i--) {
rts.append(str.charAt(i - 1));
}
System.out.println("顛倒過來:" + rts.toString());
}