可以自己来做啊class test
{
final static int NUM_LEN = 4;
public static void main (String args[]) throws Exception
{
System.out.println(format(2) + format(300) + "\r\n" + format(10) + format(20));
}
static String format(int num) throws Exception
{
String tmp = String.valueOf(num);
int len = tmp.length();
if (len > NUM_LEN)
throw new Exception("Number value out of range");
int diff = NUM_LEN - len;
for (int i=0; i
thanks so much for making this method yourself.
well, nothing to say. thank you for showing so much effort!