怎样将字符串“0023”加1,变成“0024”?
我先从数据库里得到code列的最大值“0023”,但是要是转化为int型后会丢失掉前两位0,,,,我又想保持四位不变的基础上加1,,该怎么做?

解决方案 »

  1.   

    java.text.DecimalFormat
    DecimalFormat ff = new DecimalFormat("0000");
    int i=5;
    String iS = ff.format(i);
      

  2.   

    学习中
    import java.text.DecimalFormat;
    public class Netwk {
        public Netwk() {
        }
        public static void main(String[] args) 
        {
            int a=Integer.parseInt("0023");
            a=a+1;
            DecimalFormat df = new DecimalFormat("0000");
            String i = df.format(a);
            System.out.println(i);    }}
      

  3.   

    搞定了,多谢AWUSOFT了,20分不成敬意