Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Left pads a number with zeros
     * 
     * @param num
     *            The number to pad with zeros
     * @param zeros
     *            The amount of zeros to pad the number with
     * @return A String with the number properly padded
     */
    public static String zfill(int num, int zeros) {
        String n = String.valueOf(num), z_filled = n;
        for (int i = 0; i < (zeros - n.length()); i++)
            z_filled = "0" + z_filled;
        return z_filled;
    }
}