最佳方案:使用正则

String str = "000000001234034120";
String newStr = str.replaceAll("^(0+)", "");
System.out.println(newStr);
package com.exmyth.test.string;

public class StrTest04 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "";// 测试用字符串
int len = str.length();// 取得字符串的长度
int index = ;// 预定义第一个非零字符串的位置 char strs[] = str.toCharArray();// 将字符串转化成字符数组
for (int i = ; i < len; i++) {
if ('' != strs[i]) {
index = i;// 找到非零字符串并跳出
break;
}
}
String strLast = str.substring(index, len);// 截取字符串
System.out.println(strLast);// 得到结果 strLast
} }

最新文章

  1. radio 切换内容
  2. Android开发之Notification通知
  3. 数论初步(费马小定理) - Happy 2004
  4. Python - 多版本共存与虚拟独立环境
  5. 关于Git的stash命令
  6. xxx is not in the sudoers file.This incident will be reported.的解决方法
  7. CentOS6.3挂载读写NTFS分区
  8. Android:ListViewAdapter
  9. ice调通过iceReplica用所有server instance的方法---客户端控制服务端的负载均衡
  10. git编译安装与常见问题解决
  11. nodeJS之路径PATH模块
  12. 适合初学者的一个分布式环境搭建过程(spring boot + zookeeper + dubbo + mybatis + mysql)
  13. SBT实操指南
  14. 2017-9-15-Linux移植:WinSCP软件 &amp; SSH Server开启
  15. [luogu1351][联合权值]
  16. ORA-00600: internal error code, arguments: [kgl-no-mutex-held]
  17. PAT 团体程序设计天梯赛 L1-046 整除光棍(模拟除法)
  18. 在Objc项目中调用Swift
  19. 【[SHOI2007]善意的投票】
  20. Centos 从零开始 (二)

热门文章

  1. WPF提示框效果
  2. JavaScript学习总结【10】、DOM 事件
  3. AS3的数据类型和定义
  4. linux上配置subversion服务器端安装配置并使用svn,windows本地检出,设置同步更新服务器的钩子
  5. CANoe 入门 Step by step系列(三)简单例子的剖析【转】
  6. bcov进行覆盖率统计
  7. jdk各个版本
  8. asp.net学习
  9. document.styleSheets
  10. 【POJ3208】 (DP)