去掉字符前面的0

  • A+
所属分类:Java

 0050580去掉前面的0怎么去掉,结果等于50580

方法一:

String str = "0050580";

 System.out.println(str.replaceFirst("^0*", ""));

方法二:

String str = (new Integer("0050580")).toString();

 

ZPY

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: