public class Test{
  public static void main(String[] args){
    String str = "0001";
    for(int i = 1; i < 1000; i++){
      int temp = Integer.parseInt(str);
      temp++;
      str = Integer.toString(temp);
      for(int t = str.length(); t < 5; t++){
        str = "0" + str;
      }
      System.out.println("the value is " + str);
    }
  }
}
我已经试过了,你可以根据你的需要进行必要的修改