package test;
import java.util.Scanner;
/**
* java数字转换为字符串,长度不够前面补0
* @author Administrator
*
*/
public class test4 {
private static final String FORMAT = “0000000000″;
/**
* @param args
*/
public static void main(String[] args) {
test4 t = new test4();
System.out.println(t.haoAddOne(FORMAT));
}
public static String haoAddOne(String liuShuiHao){
Integer intHao = Integer.parseInt(liuShuiHao);
intHao++;
Scanner input = new Scanner(System.in);
String strHao = intHao.toString();
System.out.println(“请输入数字:”);
strHao = input.next();
while (strHao.length() < liuShuiHao.length())
strHao = “0″ + strHao;
return strHao;
}
} |