题解 | #数字颠倒#
数字颠倒
http://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
String s = String.valueOf(a);
StringBuffer sb = new StringBuffer(s).reverse();
System.out.println(sb);
}
}
把int用String中的valueOf()方法转换为String型,再由StringBuffer中的reverse翻转