给定一串数字,从中删除前导零。

public class Test {
	public static void main(String[] args) {
		String str = "00000123569";
		System.out.println(removeZero(str)); // 123569
		str = "000012356090";
		System.out.println(removeZero(str)); // 12356090
	}

	public static String removeZero(String str) {
		int len = str.length(), i = 0;
		while (i < len && str.charAt(i) == '0') {
			i++;
		}
		return str.substring(i);
	}
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2023-02-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2021-12-07
  • 2022-01-07
相关资源
相似解决方案