前言LeetCode答案,语言Java 问题 https://leetcode-cn.com/problems/reverse-integer/ 源代码12345678910111213141516171819202122232425262728293031323334class Solution { public int reverse(int x) { String str = Integer.toString(x); char[] result = new char[str.length()]; if ((str.charAt(0)+"").equals("-")) { result[0] = "-".charAt(0); int index = 1; for (int i = str.length()-1; i > 0; i--) { result[index] = str.charAt(i); index++; } } else { int index = 0; for (int i = str.length()-1; i >= 0; i--) { result[index] = str.charAt(i); index++; } } String res = new String(result); int r = 0; try { r = Integer.parseInt(res); } catch (Exception e) { return 0; } return r; }} 完成