author: Blankj blog : http://blankj.com time : 2017/04/19 desc :
| 9 | * </pre> |
| 10 | */ |
| 11 | public class Solution { |
| 12 | public int reverse(int x) { |
| 13 | long res = 0; |
| 14 | for (; x != 0; x /= 10) |
| 15 | res = res * 10 + x % 10; |
| 16 | return res > Integer.MAX_VALUE || res < Integer.MIN_VALUE ? 0 : (int) res; |
| 17 | } |
| 18 | |
| 19 | public static void main(String[] args) { |
| 20 | Solution solution = new Solution(); |
| 21 | System.out.println(solution.reverse(123)); |
| 22 | System.out.println(solution.reverse(-123)); |
| 23 | System.out.println(solution.reverse(100)); |
| 24 | System.out.println(solution.reverse(1000000003)); |
| 25 | } |
| 26 | } |
nothing calls this directly
no outgoing calls
no test coverage detected