把它的各位數字前后顛倒一下?
代碼如下:
import java.util.Scanner;public class ReverseNumber { public static void main(String[] args) { Scanner scanner = new Scanner(System.in)
; System.out.println("請輸入一個整數:")
; int num = scanner.nextInt()
; StringBuilder stringBuilder = new StringBuilder()
; String reverseStr = stringBuilder.append(num).reverse().toString()
; System.out.println(reverseStr)
; //如果想要整型,再轉換一次 int reverseNum = Integer.valueOf(reverseStr)
;// System.out.println(reverseNum); }}